﻿@{
    ViewBag.Title = "" + FOResource.UI.Layout.HomeEquityLoan + "";
    Layout = "~/Views/Shared/_SUBLayout1.cshtml";
    var plan = (List<FOModels.HomeLoanTrust.HomeLoanPlanModels>)ViewBag.HomeLoanPlan;
    var shorttemloan = (List<FOModels.HomeEquityLoan.HomeEquityLoanModels>)ViewBag.HomeEquityLoan;
    var i = 1;
    var j = 1;
    var ProDes = (FOModels.Product.ProductModels)ViewBag.ProDes;
    double temp = 50000000;
    double interest_payment = 0;
    double debit_payment = 0;
    double totaltemp = 0;
    double totalinterest_payment = 0;
    double totaldebit_payment = 0;
}

<style>
    .slider1 {
        background: #144060 !important;
        height: 7px !important;
        position: relative;
        cursor: pointer;
        border: 1px solid #333 !important;
        width: 280px !important;
        float: left !important;
        clear: right !important;
        margin-top: 10px !important;
        margin-bottom: 30px !important;
        border-radius: 5px !important;
        -moz-border-radius: 5px !important;
        -webkit-border-radius: 5px !important;
        box-shadow: inset 0 0 8px #000 !important;
        -webkit-box-shadow: inset 0 0 8px #000 !important;
    }

    #vn-box {
        margin-left: 20px;
    }

    .ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default {
        background: #fff url("../Content/images/h30.png") repeat-x 0 0;
        height: 20px;
        width: 20px;
        top: -10px;
        position: absolute;
        display: block;
        margin-top: 1px;
        border: 1px solid #000;
        cursor: move;
        box-shadow: 0 0 6px #000;
        -moz-box-shadow: 0 0 6px #000;
        -webkit-box-shadow: 0 0 6px #000;
        border-radius: 14px;
        -moz-border-radius: 14px;
        -webkit-border-radius: 14px;
        margin-left: -.6em;
    }

    .ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus {
        background: #fff url("../Content/images/h30.png") repeat-x 0 0;
        height: 20px;
        width: 20px;
        top: -10px;
        position: absolute;
        display: block;
        margin-top: 1px;
        border: 1px solid #000;
        cursor: move;
        box-shadow: 0 0 6px #000;
        -moz-box-shadow: 0 0 6px #000;
        -webkit-box-shadow: 0 0 6px #000;
        border-radius: 14px;
        -moz-border-radius: 14px;
        -webkit-border-radius: 14px;
        margin-left: -.6em;
    }
</style>
<script src="@Url.Content("~/Content/js/jquery-ui.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Content/js/jquery-1.9.1.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Content/js/jquery-ui.js")" type="text/javascript"></script>
<script type="text/javascript" src="@Url.Content("~/Content/js/jquery.smoothDivScroll-1.0.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Content/js/jquery.smoothDivScroll-1.0-min.js")"></script>
<script src="@Url.Content("~/Content/js/jquery.fancybox.js")" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        var lang = $("#CurrentLangCode").html();
        if (lang == "vi-VN") {
            $("#amount-homeequityloan").change(function () {

                var a = $(this).val().replace(".", "").replace(".", "").replace(".", "");
                $("#slider_amount").slider("value", $(this).val());
                var max = $("#slider_amount").slider("option", "max");
                var min = $("#slider_amount").slider("option", "min");
                $("#slider_amount").slider("value", a);
                if (a > max) {
                    $("#amount-homeequityloan").val(number_format($("#slider_amount").slider("option", "max"), 0, ",", "."));
                }
                if (a < min) {
                    $("#amount-homeequityloan").val(number_format($("#slider_amount").slider("option", "min"), 0, ",", "."));
                }
                a = $(this).val().replace(".", "").replace(".", "").replace(".", "");
                var AppUrl = $("#AppUrl").text();
                var val = $("#amount-homeequityloan").val().replace(".", "").replace(".", "").replace(".", "");
                var val_cate = $("#rel_cate").attr("rel");
                var val_month = $("#years-homeequityloan").val();
                var ba = parseFloat(a);
                $("#amount-homeequityloan").val(number_format(a, 0, ",", "."));
                var temp = ba;
                var interest_payment = 0;
                var debit_payment = 0;
                var totaltemp = 0;
                var totalinterest_payment = 0;
                var totaldebit_payment = 0;
                var totalmonthlypayment = 0;
                var monthlypayment = 0;
                $.ajax({
                    type: "post",
                    url: AppUrl + "/HomeEquityLoan/getHomeEquityLoan",
                    data: { planid: val_cate, balance: ba, years: val_month },
                    dataType: "json",
                    success: function (rvdata) {
                        var htmlcode = "";
                        if (rvdata.length > 0) {
                            if (val_cate == 1) {
                                $(rvdata).each(function (index, item) {
                                    htmlcode += "<tr>";
                                    htmlcode += " <td class='td-bank-saving'>";
                                    htmlcode += " <a title='Xem chi tiết' href='" + AppUrl + "/home-equity-loan/" + convertounsign(item.CompanyName).toLowerCase() + "/" + convertounsign(item.HomeEquityLoanName).toLowerCase() + "/" + item.HomeEquityLoanID + "'><img alt='' src='/Content/UpLoad/Images/" + item.CompanyImg + "' /></a>";
                                    htmlcode += "<p class='bank-title'><a title='" + item.CompanyName + "' href='" + AppUrl + "/home-equity-loan/" + convertounsign(item.CompanyName).toLowerCase() + "/" + item.CompanyID + "'>" + item.CompanyName + "</a>" + item.HomeEquityLoanName + "</p>";
                                    htmlcode += " </td>";
                                    htmlcode += " <td style='vertical-align:middle;'>";
                                    htmlcode += "	<p style='text-align:center;'>" + item.MaximumBalance + "</p>";
                                    htmlcode += "</td>";
                                    htmlcode += " <td style='vertical-align: middle;'>";
                                    htmlcode += " <p style='text-align: center;'>" + val_month + " Năm</p>";
                                    htmlcode += "  </td>";
                                    if (item.InterestVND != 0) {
                                        htmlcode += " <td style='vertical-align:middle;'>";
                                        htmlcode += "<p class='highlight-blue text-p'>" + item.InterestVND.toString().replace(".", ",") + " %</p>";
                                        htmlcode += " </td>";
                                        htmlcode += " <td style='vertical-align:middle;'>";
                                        htmlcode += " <a href='#table-" + convertounsign(item.HomeEquityLoanName) + "-" + item.HomeEquityLoanID + "' title='Lịch biểu trả nợ tham khảo' id='tableloanpayment-" + item.HomeEquityLoanID + "' class='table-loan-payment'>Lịch biểu trả nợ tham khảo</a>";
                                        htmlcode += " </td>";
                                    }
                                    else {
                                        htmlcode += " <td style='vertical-align:middle;' colspan='2'>";
                                        htmlcode += "<p class='highlight-blue-1 text-p'>Vui lòng nhấp vào nút tham gia để liên hệ với chúng tôi</p>";
                                        htmlcode += " </td>";
                                    }
                                    htmlcode += " <td class='td-btn'>";
                                    htmlcode += "	<a class='btn-app' href='" + AppUrl + "/home-equity-loan/apply/" + item.HomeEquityLoanID + "'>Tham gia >></a>";
                                    htmlcode += "<a href='#" + convertounsign(item.HomeEquityLoanName.toLowerCase()) + "-" + item.HomeEquityLoanID + "' class='more-link' onclick='return viewmore(this)' title='Xem thêm'>Xem thêm</a>";
                                    htmlcode += "</td>";
                                    htmlcode += " </tr>";
                                    htmlcode += "<tr id='" + convertounsign(item.HomeEquityLoanName.toLowerCase()) + "-" + item.HomeEquityLoanID + "' class='more-info' style='display: none;'>";
                                    htmlcode += "<td colspan='6'>";
                                    htmlcode += " <div class='more-info-top' >";
                                    htmlcode += " <div class='more-info-wrapper'>";
                                    htmlcode += "<h4>Quyền lợi & Tính năng</h4>";
                                    htmlcode += "<div class='item-list'>";
                                    htmlcode += item.Benefit;
                                    htmlcode += "</div>";
                                    htmlcode += "</div>";
                                    htmlcode += "<div class='more-info-wrapper'>";
                                    htmlcode += "<h4>Chi phí</h4>";
                                    htmlcode += " <div class='item-list'>";
                                    htmlcode += item.FeeContent;
                                    htmlcode += "</div>";
                                    htmlcode += " </div>";
                                    htmlcode += "<div class='more-info-wrapper'>";
                                    htmlcode += "<h4>Thông tin thêm</h4>";
                                    htmlcode += " <div class='item-list'>";
                                    htmlcode += item.MoreInfo;
                                    htmlcode += "</div>  ";
                                    htmlcode += " </div>";
                                    htmlcode += "</div>";
                                    htmlcode += "</td>";
                                    htmlcode += "</tr>";

                                    htmlcode += "    <tr  id='table-" + convertounsign(item.HomeEquityLoanName) + "-" + item.HomeEquityLoanID + "' style='display:none;'>";
                                    htmlcode += "<td>";
                                    htmlcode += "   <table class='product-table-loan'>";
                                    htmlcode += "   <tr>";
                                    htmlcode += "   <th style='width: 10%'>Tháng</th>";
                                    htmlcode += " <th>Khoảng dư nợ gốc<br />(VND)</th>";
                                    htmlcode += "  <th>Khoảng phải trả hàng tháng<br />(VND)</th>";
                                    htmlcode += "  <th>Lãi phải trả<br />(VND)</th>";
                                    htmlcode += "   <th>Nợ gốc phải trả<br /> (VND)</th>";
                                    htmlcode += " </tr>";
                                    htmlcode += "<tr>";
                                    htmlcode += "  <td></td>";
                                    htmlcode += " <td>";
                                    htmlcode += "   <p style='text-align: center;'>" + number_format(temp, 0, ",", ".") + "</p>'";
                                    htmlcode += " </td>";
                                    htmlcode += " <td></td>";
                                    htmlcode += " <td></td>";
                                    htmlcode += "    <td></td>";
                                    htmlcode += "  </tr>";

                                    for (j = 1; j <= val_month * 12; j++) {
                                        interest_payment = temp * (item.InterestVND / 100 / 12);
                                        debit_payment = ba / (val_month * 12);
                                        temp = temp - debit_payment;
                                        monthlypayment = interest_payment + debit_payment;
                                        totalmonthlypayment += monthlypayment;
                                        totaltemp += temp;
                                        totaldebit_payment += debit_payment;
                                        totalinterest_payment += interest_payment;
                                        htmlcode += "<tr>";
                                        htmlcode += " <td>";
                                        htmlcode += "     <p style='text-align: center;'>" + j + "</p>";
                                        htmlcode += " </td>";
                                        htmlcode += "  <td>";
                                        if (temp >= 1) {
                                            htmlcode += "     <p style='text-align: center;'>" + number_format(temp, 0, ",", ".") + "</p>";
                                        }
                                        else {
                                            htmlcode += "     <p style='text-align: center;'>0</p>";
                                        }
                                        htmlcode += "  </td>";
                                        htmlcode += " <td>";
                                        htmlcode += "     <p style='text-align: center;'>" + number_format(monthlypayment, 0, ",", ".") + "</p>";
                                        htmlcode += "  </td>";
                                        htmlcode += " <td>";
                                        htmlcode += "      <p style='text-align: center;'>" + number_format(interest_payment, 0, ",", ".") + "</p>";
                                        htmlcode += "  </td>";
                                        htmlcode += "  <td>";
                                        htmlcode += "      <p style='text-align: center;'>" + number_format(debit_payment, 0, ",", ".") + "</p>";
                                        htmlcode += "   </td>";
                                        htmlcode += "   </tr>";
                                    }
                                    htmlcode += " <tr>";
                                    htmlcode += "    <td colspan='2'>";
                                    htmlcode += "         <p style='text-align: center;'>Tổng</p>";
                                    htmlcode += "    </td>";
                                    htmlcode += "   <td>";
                                    htmlcode += "       <p style='text-align: center;'>" + number_format(totalmonthlypayment, 0, ",", ".") + "</p>";
                                    htmlcode += "  </td>";
                                    htmlcode += "  <td>";
                                    htmlcode += "       <p style='text-align: center;'>" + number_format(totalinterest_payment, 0, ",", ".") + "</p>";
                                    htmlcode += "   </td>";
                                    htmlcode += "  <td>";
                                    htmlcode += "       <p style='text-align: center;'>" + number_format(totaldebit_payment, 0, ",", ".") + "</p>";
                                    htmlcode += "  </td>";
                                    htmlcode += " </tr>";
                                    htmlcode += "  </table>";
                                    htmlcode += "  </td>";
                                    htmlcode += "  </tr>";
                                    temp = ba;
                                    interest_payment = 0;
                                    debit_payment = 0;
                                    totaltemp = 0;
                                    totalinterest_payment = 0;
                                    totaldebit_payment = 0;
                                    monthlypayment = 0;
                                    totalmonthlypayment = 0;
                                });
                            }
                            else {
                                var payment = 0;
                                $(rvdata).each(function (index, item) {
                                    var total = 0;
                                    for (i = 1; i <= val_month * 12; i++) {
                                        total += Math.pow((1 + (item.InterestVND / 100 / 12)), -i);
                                    }
                                    htmlcode += "<tr>";
                                    htmlcode += " <td class='td-bank-saving'>";
                                    htmlcode += " <a title='Xem chi tiết' href='" + AppUrl + "/home-equity-loan/" + convertounsign(item.CompanyName).toLowerCase() + "/" + convertounsign(item.HomeEquityLoanName).toLowerCase() + "/" + item.HomeEquityLoanID + "'><img alt='' src='/Content/UpLoad/Images/" + item.CompanyImg + "' /></a>";
                                    htmlcode += "<p class='bank-title'><a title='" + item.CompanyName + "' href='" + AppUrl + "/home-equity-loan/" + convertounsign(item.CompanyName).toLowerCase() + "/" + item.CompanyID + "'>" + item.CompanyName + "</a>" + item.HomeEquityLoanName + "</p>";
                                    htmlcode += " </td>";
                                    htmlcode += " <td style='vertical-align:middle;'>";
                                    htmlcode += "	<p style='text-align:center;'>" + item.MaximumBalance + "</p>";
                                    htmlcode += "</td>";
                                    htmlcode += " <td style='vertical-align: middle;'>";
                                    htmlcode += " <p style='text-align: center;'>" + val_month + " Năm</p>";
                                    htmlcode += "  </td>";
                                    if (item.InterestVND != 0) {
                                        htmlcode += " <td style='vertical-align:middle;'>";
                                        htmlcode += "<p class='highlight-blue text-p'>" + item.InterestVND.toString().replace(".", ",") + " %</p>";
                                        htmlcode += " </td>";
                                        htmlcode += " <td style='vertical-align:middle;'>";
                                        htmlcode += "<p class='highlight-blue text-p'>" + number_format(ba / total, 0, ",", ".") + "</p>";
                                        htmlcode += " <a href='#table-" + convertounsign(item.HomeEquityLoanName) + "-" + item.HomeEquityLoanID + "' title='Lịch biểu trả nợ tham khảo' id='tableloanpayment-" + item.HomeEquityLoanID + "'  class='table-loan-payment'>Lịch biểu trả nợ tham khảo</a>";
                                        htmlcode += " </td>";
                                    }
                                    else {
                                        htmlcode += " <td style='vertical-align:middle;' colspan='2'>";
                                        htmlcode += "<p class='highlight-blue-1 text-p'>Vui lòng nhấp vào nút tham gia để liên hệ với chúng tôi</p>";
                                        htmlcode += " </td>";
                                    }
                                    htmlcode += " <td class='td-btn'>";
                                    htmlcode += "	<a class='btn-app' href='" + AppUrl + "/home-equity-loan/apply/" + item.HomeEquityLoanID + "'>Tham gia >></a>";
                                    htmlcode += "<a href='#" + convertounsign(item.HomeEquityLoanName.toLowerCase()) + "-" + item.HomeEquityLoanID + "' class='more-link' onclick='return viewmore(this)' title='Xem thêm'>Xem thêm</a>";
                                    htmlcode += "</td>";
                                    htmlcode += " </tr>";
                                    htmlcode += "<tr id='" + convertounsign(item.HomeEquityLoanName.toLowerCase()) + "-" + item.HomeEquityLoanID + "' class='more-info' style='display: none;'>";
                                    htmlcode += "<td colspan='6'>";
                                    htmlcode += " <div class='more-info-top' >";
                                    htmlcode += " <div class='more-info-wrapper'>";
                                    htmlcode += "<h4>Quyền lợi & Tính năng</h4>";
                                    htmlcode += "<div class='item-list'>";
                                    htmlcode += item.Benefit;
                                    htmlcode += "</div>";
                                    htmlcode += "</div>";
                                    htmlcode += "<div class='more-info-wrapper'>";
                                    htmlcode += "<h4>Chi phí</h4>";
                                    htmlcode += " <div class='item-list'>";
                                    htmlcode += item.FeeContent;
                                    htmlcode += "</div>";
                                    htmlcode += " </div>";
                                    htmlcode += "<div class='more-info-wrapper'>";
                                    htmlcode += "<h4>Thông tin thêm</h4>";
                                    htmlcode += " <div class='item-list'>";
                                    htmlcode += item.MoreInfo;
                                    htmlcode += "</div>  ";
                                    htmlcode += " </div>";
                                    htmlcode += "</div>";
                                    htmlcode += "</td>";
                                    htmlcode += "</tr>";

                                    htmlcode += "    <tr  id='table-" + convertounsign(item.HomeEquityLoanName) + "-" + item.HomeEquityLoanID + "' style='display:none;'>";
                                    htmlcode += "<td>";
                                    htmlcode += "   <table class='product-table-loan'>";
                                    htmlcode += "   <tr>";
                                    htmlcode += "   <th style='width: 10%'>Tháng</th>";
                                    htmlcode += " <th>Khoảng dư nợ gốc<br />(VND)</th>";
                                    htmlcode += "  <th>Khoảng phải trả hàng tháng<br />(VND)</th>";
                                    htmlcode += "  <th>Lãi phải trả<br />(VND)</th>";
                                    htmlcode += "   <th>Nợ gốc phải trả<br /> (VND)</th>";
                                    htmlcode += " </tr>";
                                    htmlcode += "<tr>";
                                    htmlcode += "  <td></td>";
                                    htmlcode += " <td>";
                                    htmlcode += "   <p style='text-align: center;'>" + number_format(temp, 0, ",", ".") + "</p>'";
                                    htmlcode += " </td>";
                                    htmlcode += " <td></td>";
                                    htmlcode += " <td></td>";
                                    htmlcode += "    <td></td>";
                                    htmlcode += "  </tr>";

                                    for (j = 1; j <= val_month * 12; j++) {
                                        interest_payment = temp * (item.InterestVND / 100 / 12);
                                        temp = ((1 + (item.InterestVND / 100 / 12))) * temp - (ba / total);
                                        debit_payment = (ba / total) - interest_payment;
                                        totaltemp += temp;
                                        totaldebit_payment += debit_payment;
                                        totalinterest_payment += interest_payment;
                                        htmlcode += "<tr>";
                                        htmlcode += " <td>";
                                        htmlcode += "     <p style='text-align: center;'>" + j + "</p>";
                                        htmlcode += " </td>";
                                        htmlcode += "  <td>";
                                        if (temp >= 1) {
                                            htmlcode += "     <p style='text-align: center;'>" + number_format(temp, 0, ",", ".") + "</p>";
                                        }
                                        else {
                                            htmlcode += "     <p style='text-align: center;'>0</p>";
                                        }
                                        htmlcode += "  </td>";
                                        htmlcode += " <td>";
                                        htmlcode += "     <p style='text-align: center;'>" + number_format(ba / total, 0, ",", ".") + "</p>";
                                        htmlcode += "  </td>";
                                        htmlcode += " <td>";
                                        htmlcode += "      <p style='text-align: center;'>" + number_format(interest_payment, 0, ",", ".") + "</p>";
                                        htmlcode += "  </td>";
                                        htmlcode += "  <td>";
                                        htmlcode += "      <p style='text-align: center;'>" + number_format(debit_payment, 0, ",", ".") + "</p>";
                                        htmlcode += "   </td>";
                                        htmlcode += "   </tr>";
                                    }
                                    htmlcode += " <tr>";
                                    htmlcode += "    <td colspan='2'>";
                                    htmlcode += "         <p style='text-align: center;'>Tổng</p>";
                                    htmlcode += "    </td>";
                                    htmlcode += "   <td>";
                                    htmlcode += "       <p style='text-align: center;'>" + number_format((ba / total) * val_month * 12, 0, ",", ".") + "</p>";
                                    htmlcode += "  </td>";
                                    htmlcode += "  <td>";
                                    htmlcode += "       <p style='text-align: center;'>" + number_format(totalinterest_payment, 0, ",", ".") + "</p>";
                                    htmlcode += "   </td>";
                                    htmlcode += "  <td>";
                                    htmlcode += "       <p style='text-align: center;'>" + number_format(totaldebit_payment, 0, ",", ".") + "</p>";
                                    htmlcode += "  </td>";
                                    htmlcode += " </tr>";
                                    htmlcode += "  </table>";
                                    htmlcode += "  </td>";
                                    htmlcode += "  </tr>";
                                    temp = ba;
                                    interest_payment = 0;
                                    debit_payment = 0;
                                    totaltemp = 0;
                                    totalinterest_payment = 0;
                                    totaldebit_payment = 0;

                                });
                            }

                            $("#product-table tbody").html("");
                            $("#product-table tbody").append(htmlcode);
                            $("#product-table").trigger("update");
                            $('tbody > tr:visible').removeClass('odd even').filter(':even').addClass('odd').end().filter(':odd').addClass('even');
                            $(".table-loan-payment").fancybox({
                                wrapCSS: 'fancybox-custom',
                                closeClick: true,
                                openEffect: 'elastic',
                                closeEffect: 'elastic',
                                helpers: {
                                    title: {
                                        type: 'float'
                                    }
                                }
                            });
                        }
                        else {
                            htmlcode = "<tr><td colspan='6' style='margin-top: 10px;font-weight: bold;text-align: center;margin-bottom: 10px;'>Không có dữ liệu phù hợp</p></td></tr>";
                            $("#product-table tbody").html(htmlcode);

                        }
                    }
                });
            });
            $("#years-homeequityloan").change(function () {
                var a = $(this).val();
                $("#slider_year").slider("value", $(this).val());
                var max = $("#slider_year").slider("option", "max");
                var min = $("#slider_year").slider("option", "min");
                $("#slider_year").slider("value", $(this).val());
                if (a > max) {
                    $("#years-homeequityloan").val($("#slider_year").slider("option", "max"));
                }
                if (a < min) {
                    $("#years-homeequityloan").val($("#slider_year").slider("option", "min"));
                }
                var AppUrl = $("#AppUrl").text();
                var val = $("#amount-homeequityloan").val().replace(".", "").replace(".", "").replace(".", "");;
                var val_cate = $("#rel_cate").attr("rel");
                var val_month = $("#years-homeequityloan").val();
                var ba = parseFloat(val);
                var temp = ba;
                var interest_payment = 0;
                var debit_payment = 0;
                var totaltemp = 0;
                var totalinterest_payment = 0;
                var totaldebit_payment = 0;
                var totalmonthlypayment = 0;
                var monthlypayment = 0;
                $.ajax({
                    type: "post",
                    url: AppUrl + "/HomeEquityLoan/getHomeEquityLoan",
                    data: { planid: val_cate, balance: ba, years: val_month },
                    dataType: "json",
                    success: function (rvdata) {
                        var htmlcode = "";
                        if (rvdata.length > 0) {
                            if (val_cate == 1) {
                                $(rvdata).each(function (index, item) {
                                    htmlcode += "<tr>";
                                    htmlcode += " <td class='td-bank-saving'>";
                                    htmlcode += " <a title='Xem chi tiết' href='" + AppUrl + "/home-equity-loan/" + convertounsign(item.CompanyName).toLowerCase() + "/" + convertounsign(item.HomeEquityLoanName).toLowerCase() + "/" + item.HomeEquityLoanID + "'><img alt='' src='/Content/UpLoad/Images/" + item.CompanyImg + "' /></a>";
                                    htmlcode += "<p class='bank-title'><a title='" + item.CompanyName + "' href='" + AppUrl + "/home-equity-loan/" + convertounsign(item.CompanyName).toLowerCase() + "/" + item.CompanyID + "'>" + item.CompanyName + "</a>" + item.HomeEquityLoanName + "</p>";
                                    htmlcode += " </td>";
                                    htmlcode += " <td style='vertical-align:middle;'>";
                                    htmlcode += "	<p style='text-align:center;'>" + item.MaximumBalance + "</p>";
                                    htmlcode += "</td>";
                                    htmlcode += " <td style='vertical-align: middle;'>";
                                    htmlcode += " <p style='text-align: center;'>" + val_month + " Năm</p>";
                                    htmlcode += "  </td>";
                                    if (item.InterestVND != 0) {
                                        htmlcode += " <td style='vertical-align:middle;'>";
                                        htmlcode += "<p class='highlight-blue text-p'>" + item.InterestVND.toString().replace(".", ",") + " %</p>";
                                        htmlcode += " </td>";
                                        htmlcode += " <td style='vertical-align:middle;'>";
                                        htmlcode += " <a href='#table-" + convertounsign(item.HomeEquityLoanName) + "-" + item.HomeEquityLoanID + "' title='Lịch biểu trả nợ tham khảo' id='tableloanpayment-" + item.HomeEquityLoanID + "' class='table-loan-payment'>Lịch biểu trả nợ tham khảo</a>";
                                        htmlcode += " </td>";
                                    }
                                    else {
                                        htmlcode += " <td style='vertical-align:middle;' colspan='2'>";
                                        htmlcode += "<p class='highlight-blue-1 text-p'>Vui lòng nhấp vào nút tham gia để liên hệ với chúng tôi</p>";
                                        htmlcode += " </td>";
                                    }
                                    htmlcode += " <td class='td-btn'>";
                                    htmlcode += "	<a class='btn-app' href='" + AppUrl + "/home-equity-loan/apply/" + item.HomeEquityLoanID + "'>Tham gia >></a>";
                                    htmlcode += "<a href='#" + convertounsign(item.HomeEquityLoanName.toLowerCase()) + "-" + item.HomeEquityLoanID + "' class='more-link' onclick='return viewmore(this)' title='Xem thêm'>Xem thêm</a>";
                                    htmlcode += "</td>";
                                    htmlcode += " </tr>";
                                    htmlcode += "<tr id='" + convertounsign(item.HomeEquityLoanName.toLowerCase()) + "-" + item.HomeEquityLoanID + "' class='more-info' style='display: none;'>";
                                    htmlcode += "<td colspan='6'>";
                                    htmlcode += " <div class='more-info-top' >";
                                    htmlcode += " <div class='more-info-wrapper'>";
                                    htmlcode += "<h4>Quyền lợi & Tính năng</h4>";
                                    htmlcode += "<div class='item-list'>";
                                    htmlcode += item.Benefit;
                                    htmlcode += "</div>";
                                    htmlcode += "</div>";
                                    htmlcode += "<div class='more-info-wrapper'>";
                                    htmlcode += "<h4>Chi phí</h4>";
                                    htmlcode += " <div class='item-list'>";
                                    htmlcode += item.FeeContent;
                                    htmlcode += "</div>";
                                    htmlcode += " </div>";
                                    htmlcode += "<div class='more-info-wrapper'>";
                                    htmlcode += "<h4>Thông tin thêm</h4>";
                                    htmlcode += " <div class='item-list'>";
                                    htmlcode += item.MoreInfo;
                                    htmlcode += "</div>  ";
                                    htmlcode += " </div>";
                                    htmlcode += "</div>";
                                    htmlcode += "</td>";
                                    htmlcode += "</tr>";

                                    htmlcode += "    <tr  id='table-" + convertounsign(item.HomeEquityLoanName) + "-" + item.HomeEquityLoanID + "' style='display:none;'>";
                                    htmlcode += "<td>";
                                    htmlcode += "   <table class='product-table-loan'>";
                                    htmlcode += "   <tr>";
                                    htmlcode += "   <th style='width: 10%'>Tháng</th>";
                                    htmlcode += " <th>Khoảng dư nợ gốc<br />(VND)</th>";
                                    htmlcode += "  <th>Khoảng phải trả hàng tháng<br />(VND)</th>";
                                    htmlcode += "  <th>Lãi phải trả<br />(VND)</th>";
                                    htmlcode += "   <th>Nợ gốc phải trả<br /> (VND)</th>";
                                    htmlcode += " </tr>";
                                    htmlcode += "<tr>";
                                    htmlcode += "  <td></td>";
                                    htmlcode += " <td>";
                                    htmlcode += "   <p style='text-align: center;'>" + number_format(temp, 0, ",", ".") + "</p>'";
                                    htmlcode += " </td>";
                                    htmlcode += " <td></td>";
                                    htmlcode += " <td></td>";
                                    htmlcode += "    <td></td>";
                                    htmlcode += "  </tr>";

                                    for (j = 1; j <= val_month * 12; j++) {
                                        interest_payment = temp * (item.InterestVND / 100 / 12);
                                        debit_payment = ba / (val_month * 12);
                                        temp = temp - debit_payment;
                                        monthlypayment = interest_payment + debit_payment;
                                        totalmonthlypayment += monthlypayment;
                                        totaltemp += temp;
                                        totaldebit_payment += debit_payment;
                                        totalinterest_payment += interest_payment;
                                        htmlcode += "<tr>";
                                        htmlcode += " <td>";
                                        htmlcode += "     <p style='text-align: center;'>" + j + "</p>";
                                        htmlcode += " </td>";
                                        htmlcode += "  <td>";
                                        if (temp >= 1) {
                                            htmlcode += "     <p style='text-align: center;'>" + number_format(temp, 0, ",", ".") + "</p>";
                                        }
                                        else {
                                            htmlcode += "     <p style='text-align: center;'>0</p>";
                                        }
                                        htmlcode += "  </td>";
                                        htmlcode += " <td>";
                                        htmlcode += "     <p style='text-align: center;'>" + number_format(monthlypayment, 0, ",", ".") + "</p>";
                                        htmlcode += "  </td>";
                                        htmlcode += " <td>";
                                        htmlcode += "      <p style='text-align: center;'>" + number_format(interest_payment, 0, ",", ".") + "</p>";
                                        htmlcode += "  </td>";
                                        htmlcode += "  <td>";
                                        htmlcode += "      <p style='text-align: center;'>" + number_format(debit_payment, 0, ",", ".") + "</p>";
                                        htmlcode += "   </td>";
                                        htmlcode += "   </tr>";
                                    }
                                    htmlcode += " <tr>";
                                    htmlcode += "    <td colspan='2'>";
                                    htmlcode += "         <p style='text-align: center;'>Tổng</p>";
                                    htmlcode += "    </td>";
                                    htmlcode += "   <td>";
                                    htmlcode += "       <p style='text-align: center;'>" + number_format(totalmonthlypayment, 0, ",", ".") + "</p>";
                                    htmlcode += "  </td>";
                                    htmlcode += "  <td>";
                                    htmlcode += "       <p style='text-align: center;'>" + number_format(totalinterest_payment, 0, ",", ".") + "</p>";
                                    htmlcode += "   </td>";
                                    htmlcode += "  <td>";
                                    htmlcode += "       <p style='text-align: center;'>" + number_format(totaldebit_payment, 0, ",", ".") + "</p>";
                                    htmlcode += "  </td>";
                                    htmlcode += " </tr>";
                                    htmlcode += "  </table>";
                                    htmlcode += "  </td>";
                                    htmlcode += "  </tr>";
                                    temp = ba;
                                    interest_payment = 0;
                                    debit_payment = 0;
                                    totaltemp = 0;
                                    totalinterest_payment = 0;
                                    totaldebit_payment = 0;
                                    monthlypayment = 0;
                                    totalmonthlypayment = 0;
                                });
                            }
                            else {
                                var payment = 0;
                                $(rvdata).each(function (index, item) {
                                    var total = 0;
                                    for (i = 1; i <= val_month * 12; i++) {
                                        total += Math.pow((1 + (item.InterestVND / 100 / 12)), -i);
                                    }
                                    htmlcode += "<tr>";
                                    htmlcode += " <td class='td-bank-saving'>";
                                    htmlcode += " <a title='Xem chi tiết' href='" + AppUrl + "/home-equity-loan/" + convertounsign(item.CompanyName).toLowerCase() + "/" + convertounsign(item.HomeEquityLoanName).toLowerCase() + "/" + item.HomeEquityLoanID + "'><img alt='' src='/Content/UpLoad/Images/" + item.CompanyImg + "' /></a>";
                                    htmlcode += "<p class='bank-title'><a title='" + item.CompanyName + "' href='" + AppUrl + "/home-equity-loan/" + convertounsign(item.CompanyName).toLowerCase() + "/" + item.CompanyID + "'>" + item.CompanyName + "</a>" + item.HomeEquityLoanName + "</p>";
                                    htmlcode += " </td>";
                                    htmlcode += " <td style='vertical-align:middle;'>";
                                    htmlcode += "	<p style='text-align:center;'>" + item.MaximumBalance + "</p>";
                                    htmlcode += "</td>";
                                    htmlcode += " <td style='vertical-align: middle;'>";
                                    htmlcode += " <p style='text-align: center;'>" + val_month + " Năm</p>";
                                    htmlcode += "  </td>";
                                    if (item.InterestVND != 0) {
                                        htmlcode += " <td style='vertical-align:middle;'>";
                                        htmlcode += "<p class='highlight-blue text-p'>" + item.InterestVND.toString().replace(".", ",") + " %</p>";
                                        htmlcode += " </td>";
                                        htmlcode += " <td style='vertical-align:middle;'>";
                                        htmlcode += "<p class='highlight-blue text-p'>" + number_format(ba / total, 0, ",", ".") + "</p>";
                                        htmlcode += " <a href='#table-" + convertounsign(item.HomeEquityLoanName) + "-" + item.HomeEquityLoanID + "' title='Lịch biểu trả nợ tham khảo' id='tableloanpayment-" + item.HomeEquityLoanID + "'  class='table-loan-payment'>Lịch biểu trả nợ tham khảo</a>";
                                        htmlcode += " </td>";
                                    }
                                    else {
                                        htmlcode += " <td style='vertical-align:middle;' colspan='2'>";
                                        htmlcode += "<p class='highlight-blue-1 text-p'>Vui lòng nhấp vào nút tham gia để liên hệ với chúng tôi</p>";
                                        htmlcode += " </td>";
                                    }
                                    htmlcode += " <td class='td-btn'>";
                                    htmlcode += "	<a class='btn-app' href='" + AppUrl + "/home-equity-loan/apply/" + item.HomeEquityLoanID + "'>Tham gia >></a>";
                                    htmlcode += "<a href='#" + convertounsign(item.HomeEquityLoanName.toLowerCase()) + "-" + item.HomeEquityLoanID + "' class='more-link' onclick='return viewmore(this)' title='Xem thêm'>Xem thêm</a>";
                                    htmlcode += "</td>";
                                    htmlcode += " </tr>";
                                    htmlcode += "<tr id='" + convertounsign(item.HomeEquityLoanName.toLowerCase()) + "-" + item.HomeEquityLoanID + "' class='more-info' style='display: none;'>";
                                    htmlcode += "<td colspan='6'>";
                                    htmlcode += " <div class='more-info-top' >";
                                    htmlcode += " <div class='more-info-wrapper'>";
                                    htmlcode += "<h4>Quyền lợi & Tính năng</h4>";
                                    htmlcode += "<div class='item-list'>";
                                    htmlcode += item.Benefit;
                                    htmlcode += "</div>";
                                    htmlcode += "</div>";
                                    htmlcode += "<div class='more-info-wrapper'>";
                                    htmlcode += "<h4>Chi phí</h4>";
                                    htmlcode += " <div class='item-list'>";
                                    htmlcode += item.FeeContent;
                                    htmlcode += "</div>";
                                    htmlcode += " </div>";
                                    htmlcode += "<div class='more-info-wrapper'>";
                                    htmlcode += "<h4>Thông tin thêm</h4>";
                                    htmlcode += " <div class='item-list'>";
                                    htmlcode += item.MoreInfo;
                                    htmlcode += "</div>  ";
                                    htmlcode += " </div>";
                                    htmlcode += "</div>";
                                    htmlcode += "</td>";
                                    htmlcode += "</tr>";

                                    htmlcode += "    <tr  id='table-" + convertounsign(item.HomeEquityLoanName) + "-" + item.HomeEquityLoanID + "' style='display:none;'>";
                                    htmlcode += "<td>";
                                    htmlcode += "   <table class='product-table-loan'>";
                                    htmlcode += "   <tr>";
                                    htmlcode += "   <th style='width: 10%'>Tháng</th>";
                                    htmlcode += " <th>Khoảng dư nợ gốc<br />(VND)</th>";
                                    htmlcode += "  <th>Khoảng phải trả hàng tháng<br />(VND)</th>";
                                    htmlcode += "  <th>Lãi phải trả<br />(VND)</th>";
                                    htmlcode += "   <th>Nợ gốc phải trả<br /> (VND)</th>";
                                    htmlcode += " </tr>";
                                    htmlcode += "<tr>";
                                    htmlcode += "  <td></td>";
                                    htmlcode += " <td>";
                                    htmlcode += "   <p style='text-align: center;'>" + number_format(temp, 0, ",", ".") + "</p>'";
                                    htmlcode += " </td>";
                                    htmlcode += " <td></td>";
                                    htmlcode += " <td></td>";
                                    htmlcode += "    <td></td>";
                                    htmlcode += "  </tr>";

                                    for (j = 1; j <= val_month * 12; j++) {
                                        interest_payment = temp * (item.InterestVND / 100 / 12);
                                        temp = ((1 + (item.InterestVND / 100 / 12))) * temp - (ba / total);
                                        debit_payment = (ba / total) - interest_payment;
                                        totaltemp += temp;
                                        totaldebit_payment += debit_payment;
                                        totalinterest_payment += interest_payment;
                                        htmlcode += "<tr>";
                                        htmlcode += " <td>";
                                        htmlcode += "     <p style='text-align: center;'>" + j + "</p>";
                                        htmlcode += " </td>";
                                        htmlcode += "  <td>";
                                        if (temp >= 1) {
                                            htmlcode += "     <p style='text-align: center;'>" + number_format(temp, 0, ",", ".") + "</p>";
                                        }
                                        else {
                                            htmlcode += "     <p style='text-align: center;'>0</p>";
                                        }
                                        htmlcode += "  </td>";
                                        htmlcode += " <td>";
                                        htmlcode += "     <p style='text-align: center;'>" + number_format(ba / total, 0, ",", ".") + "</p>";
                                        htmlcode += "  </td>";
                                        htmlcode += " <td>";
                                        htmlcode += "      <p style='text-align: center;'>" + number_format(interest_payment, 0, ",", ".") + "</p>";
                                        htmlcode += "  </td>";
                                        htmlcode += "  <td>";
                                        htmlcode += "      <p style='text-align: center;'>" + number_format(debit_payment, 0, ",", ".") + "</p>";
                                        htmlcode += "   </td>";
                                        htmlcode += "   </tr>";
                                    }
                                    htmlcode += " <tr>";
                                    htmlcode += "    <td colspan='2'>";
                                    htmlcode += "         <p style='text-align: center;'>Tổng</p>";
                                    htmlcode += "    </td>";
                                    htmlcode += "   <td>";
                                    htmlcode += "       <p style='text-align: center;'>" + number_format((ba / total) * val_month * 12, 0, ",", ".") + "</p>";
                                    htmlcode += "  </td>";
                                    htmlcode += "  <td>";
                                    htmlcode += "       <p style='text-align: center;'>" + number_format(totalinterest_payment, 0, ",", ".") + "</p>";
                                    htmlcode += "   </td>";
                                    htmlcode += "  <td>";
                                    htmlcode += "       <p style='text-align: center;'>" + number_format(totaldebit_payment, 0, ",", ".") + "</p>";
                                    htmlcode += "  </td>";
                                    htmlcode += " </tr>";
                                    htmlcode += "  </table>";
                                    htmlcode += "  </td>";
                                    htmlcode += "  </tr>";
                                    temp = ba;
                                    interest_payment = 0;
                                    debit_payment = 0;
                                    totaltemp = 0;
                                    totalinterest_payment = 0;
                                    totaldebit_payment = 0;

                                });
                            }

                            $("#product-table tbody").html("");
                            $("#product-table tbody").append(htmlcode);
                            $("#product-table").trigger("update");
                            $('tbody > tr:visible').removeClass('odd even').filter(':even').addClass('odd').end().filter(':odd').addClass('even');
                            $(".table-loan-payment").fancybox({
                                wrapCSS: 'fancybox-custom',
                                closeClick: true,
                                openEffect: 'elastic',
                                closeEffect: 'elastic',
                                helpers: {
                                    title: {
                                        type: 'float'
                                    }
                                }
                            });
                        }
                        else {
                            htmlcode = "<tr><td colspan='6' style='margin-top: 10px;font-weight: bold;text-align: center;margin-bottom: 10px;'>Không có dữ liệu phù hợp</p></td></tr>";
                            $("#product-table tbody").html(htmlcode);

                        }
                    }
                });
            });
        }
        else {
            $("#amount-homeequityloan").change(function () {

                var a = $(this).val().replace(",", "").replace(",", "").replace(",", "");
                $("#slider_amount").slider("value", $(this).val());
                var max = $("#slider_amount").slider("option", "max");
                var min = $("#slider_amount").slider("option", "min");
                $("#slider_amount").slider("value", a);
                if (a > max) {
                    $("#amount-homeequityloan").val(number_format($("#slider_amount").slider("option", "max"), 0, ".", ","));
                }
                if (a < min) {
                    $("#amount-homeequityloan").val(number_format($("#slider_amount").slider("option", "min"), 0, ".", ","));
                }
                a = $(this).val().replace(",", "").replace(",", "").replace(",", "");
                var AppUrl = $("#AppUrl").text();
                var val = $("#amount-homeequityloan").val().replace(",", "").replace(",", "").replace(",", "");
                var val_cate = $("#rel_cate").attr("rel");
                var val_month = $("#years-homeequityloan").val();
                var ba = parseFloat(a);
                $("#amount-homeequityloan").val(number_format(a, 0, ".", ","));
                var temp = ba;
                var interest_payment = 0;
                var debit_payment = 0;
                var totaltemp = 0;
                var totalinterest_payment = 0;
                var totaldebit_payment = 0;
                var totalmonthlypayment = 0;
                var monthlypayment = 0;
                $.ajax({
                    type: "post",
                    url: AppUrl + "/HomeEquityLoan/getHomeEquityLoan",
                    data: { planid: val_cate, balance: ba, years: val_month },
                    dataType: "json",
                    success: function (rvdata) {
                        var htmlcode = "";
                        if (rvdata.length > 0) {

                            if (val_cate == 1) {
                                $(rvdata).each(function (index, item) {
                                    htmlcode += "<tr>";
                                    htmlcode += " <td class='td-bank-saving'>";
                                    htmlcode += " <a title='View Detail' href='" + AppUrl + "/home-equity-loan/" + convertounsign(item.CompanyName).toLowerCase() + "/" + convertounsign(item.HomeEquityLoanName).toLowerCase() + "/" + item.HomeEquityLoanID + "'><img alt='' src='/Content/UpLoad/Images/" + item.CompanyImg + "' /></a>";
                                    htmlcode += "<p class='bank-title'><a title='" + item.CompanyName + "' href='" + AppUrl + "/home-equity-loan/" + convertounsign(item.CompanyName).toLowerCase() + "/" + item.CompanyID + "'>" + item.CompanyName + "</a>" + item.HomeEquityLoanName + "</p>";
                                    htmlcode += " </td>";
                                    htmlcode += " <td style='vertical-align:middle;'>";
                                    htmlcode += "	<p style='text-align:center;'>" + item.MaximumBalance.replace(".", ",").replace(".", ",").replace(".", ",") + "</p>";
                                    htmlcode += "</td>";
                                    htmlcode += " <td style='vertical-align: middle;'>";
                                    htmlcode += " <p style='text-align: center;'>" + val_month + " Year</p>";
                                    htmlcode += "  </td>";
                                    if (item.InterestVND != 0) {
                                        htmlcode += " <td style='vertical-align:middle;'>";
                                        htmlcode += "<p class='highlight-blue text-p'>" + item.InterestVND + " %</p>";
                                        htmlcode += " </td>";
                                        htmlcode += " <td style='vertical-align:middle;'>";
                                        htmlcode += " <a href='#table-" + convertounsign(item.HomeEquityLoanName) + "-" + item.HomeEquityLoanID + "' title='Reference repayment schedule' id='tableloanpayment-" + item.HomeEquityLoanID + "'  class='table-loan-payment'>Reference repayment schedule</a>";
                                        htmlcode += " </td>";
                                    }
                                    else {
                                        htmlcode += " <td style='vertical-align:middle;' colspan='2'>";
                                        htmlcode += "<p class='highlight-blue-1 text-p'>Please kindly click on \"Apply\" button to contact us</p>";
                                        htmlcode += " </td>";
                                    }
                                    htmlcode += " <td class='td-btn'>";
                                    htmlcode += "	<a class='btn-app' href='" + AppUrl + "/home-equity-loan/apply/" + item.HomeEquityLoanID + "'>Apply >></a>";
                                    htmlcode += "<a href='#" + convertounsign(item.HomeEquityLoanName.toLowerCase()) + "-" + item.HomeEquityLoanID + "' class='more-link' onclick='return viewmore(this)' title='More Info'>More Info</a>";
                                    htmlcode += "</td>";
                                    htmlcode += " </tr>";
                                    htmlcode += "<tr id='" + convertounsign(item.HomeEquityLoanName.toLowerCase()) + "-" + item.HomeEquityLoanID + "' class='more-info' style='display: none;'>";
                                    htmlcode += "<td colspan='6'>";
                                    htmlcode += " <div class='more-info-top' >";
                                    htmlcode += " <div class='more-info-wrapper'>";
                                    htmlcode += "<h4>Benefit & Feature</h4>";
                                    htmlcode += "<div class='item-list'>";
                                    htmlcode += item.Benefit;
                                    htmlcode += "</div>";
                                    htmlcode += "</div>";
                                    htmlcode += "<div class='more-info-wrapper'>";
                                    htmlcode += "<h4>Fees</h4>";
                                    htmlcode += " <div class='item-list'>";
                                    htmlcode += item.FeeContent;
                                    htmlcode += "</div>";
                                    htmlcode += " </div>";
                                    htmlcode += "<div class='more-info-wrapper'>";
                                    htmlcode += "<h4>More Infomation</h4>";
                                    htmlcode += " <div class='item-list'>";
                                    htmlcode += item.MoreInfo;
                                    htmlcode += "</div>  ";
                                    htmlcode += " </div>";
                                    htmlcode += "</div>";
                                    htmlcode += "</td>";
                                    htmlcode += "</tr>";

                                    htmlcode += "    <tr  id='table-" + convertounsign(item.HomeEquityLoanName) + "-" + item.HomeEquityLoanID + "' style='display:none;'>";
                                    htmlcode += "<td>";
                                    htmlcode += "   <table class='product-table-loan'>";
                                    htmlcode += "   <tr>";
                                    htmlcode += "   <th style='width: 10%'>Month</th>";
                                    htmlcode += " <th>Outstanding Principal<br />(VND)</th>";
                                    htmlcode += "  <th>Monthly Payable <br />(VND)</th>";
                                    htmlcode += "  <th>Interest Payable <br />(VND)</th>";
                                    htmlcode += "   <th>Original Debt Payable<br /> (VND)</th>";
                                    htmlcode += " </tr>";
                                    htmlcode += "<tr>";
                                    htmlcode += "  <td></td>";
                                    htmlcode += " <td>";
                                    htmlcode += "   <p style='text-align: center;'>" + number_format(temp, 0, ".", ",") + "</p>'";
                                    htmlcode += " </td>";
                                    htmlcode += " <td></td>";
                                    htmlcode += " <td></td>";
                                    htmlcode += "    <td></td>";
                                    htmlcode += "  </tr>";

                                    for (j = 1; j <= val_month * 12; j++) {
                                        interest_payment = temp * (item.InterestVND / 100 / 12);
                                        debit_payment = ba / (val_month * 12);
                                        temp = temp - debit_payment;
                                        monthlypayment = interest_payment + debit_payment;
                                        totalmonthlypayment += monthlypayment;
                                        totaltemp += temp;
                                        totaldebit_payment += debit_payment;
                                        totalinterest_payment += interest_payment;
                                        htmlcode += "<tr>";
                                        htmlcode += " <td>";
                                        htmlcode += "     <p style='text-align: center;'>" + j + "</p>";
                                        htmlcode += " </td>";
                                        htmlcode += "  <td>";
                                        if (temp >= 1) {
                                            htmlcode += "     <p style='text-align: center;'>" + number_format(temp, 0, ".", ",") + "</p>";
                                        }
                                        else {
                                            htmlcode += "     <p style='text-align: center;'>0</p>";
                                        }
                                        htmlcode += "  </td>";
                                        htmlcode += " <td>";
                                        htmlcode += "     <p style='text-align: center;'>" + number_format(monthlypayment, 0, ".", ",") + "</p>";
                                        htmlcode += "  </td>";
                                        htmlcode += " <td>";
                                        htmlcode += "      <p style='text-align: center;'>" + number_format(interest_payment, 0, ".", ",") + "</p>";
                                        htmlcode += "  </td>";
                                        htmlcode += "  <td>";
                                        htmlcode += "      <p style='text-align: center;'>" + number_format(debit_payment, 0, ".", ",") + "</p>";
                                        htmlcode += "   </td>";
                                        htmlcode += "   </tr>";
                                    }
                                    htmlcode += " <tr>";
                                    htmlcode += "    <td colspan='2'>";
                                    htmlcode += "         <p style='text-align: center;'>Total</p>";
                                    htmlcode += "    </td>";
                                    htmlcode += "   <td>";
                                    htmlcode += "       <p style='text-align: center;'>" + number_format(totalmonthlypayment, 0, ".", ",") + "</p>";
                                    htmlcode += "  </td>";
                                    htmlcode += "  <td>";
                                    htmlcode += "       <p style='text-align: center;'>" + number_format(totalinterest_payment, 0, ".", ",") + "</p>";
                                    htmlcode += "   </td>";
                                    htmlcode += "  <td>";
                                    htmlcode += "       <p style='text-align: center;'>" + number_format(totaldebit_payment, 0, ".", ",") + "</p>";
                                    htmlcode += "  </td>";
                                    htmlcode += " </tr>";
                                    htmlcode += "  </table>";
                                    htmlcode += "  </td>";
                                    htmlcode += "  </tr>";
                                    temp = ba;
                                    interest_payment = 0;
                                    debit_payment = 0;
                                    totaltemp = 0;
                                    totalinterest_payment = 0;
                                    totaldebit_payment = 0;
                                    monthlypayment = 0;
                                    totalmonthlypayment = 0;
                                });
                            }
                            else {
                                var payment = 0;
                                $(rvdata).each(function (index, item) {
                                    var total = 0;
                                    for (i = 1; i <= val_month * 12; i++) {
                                        total += Math.pow((1 + (item.InterestVND / 100 / 12)), -i);
                                    }
                                    htmlcode += "<tr>";
                                    htmlcode += " <td class='td-bank-saving'>";
                                    htmlcode += " <a title='Xem chi tiết' href='" + AppUrl + "/home-equity-loan/" + convertounsign(item.CompanyName).toLowerCase() + "/" + convertounsign(item.HomeEquityLoanName).toLowerCase() + "/" + item.HomeEquityLoanID + "'><img alt='' src='/Content/UpLoad/Images/" + item.CompanyImg + "' /></a>";
                                    htmlcode += "<p class='bank-title'><a title='" + item.CompanyName + "' href='" + AppUrl + "/home-equity-loan/" + convertounsign(item.CompanyName).toLowerCase() + "/" + item.CompanyID + "'>" + item.CompanyName + "</a>" + item.HomeEquityLoanName + "</p>";
                                    htmlcode += " </td>";
                                    htmlcode += " <td style='vertical-align:middle;'>";
                                    htmlcode += "	<p style='text-align:center;'>" + item.MaximumBalance.replace(".", ",").replace(".", ",").replace(".", ",") + "</p>";
                                    htmlcode += "</td>";
                                    htmlcode += " <td style='vertical-align: middle;'>";
                                    htmlcode += " <p style='text-align: center;'>" + val_month + " Year</p>";
                                    htmlcode += "  </td>";
                                    if (item.InterestVND != 0) {
                                        htmlcode += " <td style='vertical-align:middle;'>";
                                        htmlcode += "<p class='highlight-blue text-p'>" + item.InterestVND + " %</p>";
                                        htmlcode += " </td>";
                                        htmlcode += " <td style='vertical-align:middle;'>";
                                        htmlcode += "<p class='highlight-blue text-p'>" + number_format(ba / total, 0, ".", ",") + "</p>";
                                        htmlcode += " <a href='#table-" + convertounsign(item.HomeEquityLoanName) + "-" + item.HomeEquityLoanID + "' title='Reference repayment schedule' id='tableloanpayment-" + item.HomeEquityLoanID + "'  class='table-loan-payment'>Reference repayment schedule</a>";
                                        htmlcode += " </td>";
                                    }
                                    else {
                                        htmlcode += " <td style='vertical-align:middle;' colspan='2'>";
                                        htmlcode += "<p class='highlight-blue-1 text-p'>Please kindly click on \"Apply\" button to contact us</p>";
                                        htmlcode += " </td>";
                                    }
                                    htmlcode += " <td class='td-btn'>";
                                    htmlcode += "	<a class='btn-app' href='" + AppUrl + "/home-equity-loan/apply/" + item.HomeEquityLoanID + "'>Apply >></a>";
                                    htmlcode += "<a href='#" + convertounsign(item.HomeEquityLoanName.toLowerCase()) + "-" + item.HomeEquityLoanID + "' class='more-link' onclick='return viewmore(this)' title='More Info'>More Info</a>";
                                    htmlcode += "</td>";
                                    htmlcode += " </tr>";
                                    htmlcode += "<tr id='" + convertounsign(item.HomeEquityLoanName.toLowerCase()) + "-" + item.HomeEquityLoanID + "' class='more-info' style='display: none;'>";
                                    htmlcode += "<td colspan='6'>";
                                    htmlcode += " <div class='more-info-top' >";
                                    htmlcode += " <div class='more-info-wrapper'>";
                                    htmlcode += "<h4>Benefit & Feature</h4>";
                                    htmlcode += "<div class='item-list'>";
                                    htmlcode += item.Benefit;
                                    htmlcode += "</div>";
                                    htmlcode += "</div>";
                                    htmlcode += "<div class='more-info-wrapper'>";
                                    htmlcode += "<h4>Fees</h4>";
                                    htmlcode += " <div class='item-list'>";
                                    htmlcode += item.FeeContent;
                                    htmlcode += "</div>";
                                    htmlcode += " </div>";
                                    htmlcode += "<div class='more-info-wrapper'>";
                                    htmlcode += "<h4>More Infomation</h4>";
                                    htmlcode += " <div class='item-list'>";
                                    htmlcode += item.MoreInfo;
                                    htmlcode += "</div>  ";
                                    htmlcode += " </div>";
                                    htmlcode += "</div>";
                                    htmlcode += "</td>";
                                    htmlcode += "</tr>";
                                    htmlcode += "    <tr  id='table-" + convertounsign(item.HomeEquityLoanName) + "-" + item.HomeEquityLoanID + "' style='display:none;'>";
                                    htmlcode += "<td>";
                                    htmlcode += "   <table class='product-table-loan'>";
                                    htmlcode += "   <tr>";
                                    htmlcode += "   <th style='width: 10%'>Month</th>";
                                    htmlcode += " <th>Outstanding Principal<br />(VND)</th>";
                                    htmlcode += "  <th>Monthly Payable <br />(VND)</th>";
                                    htmlcode += "  <th>Interest Payable <br />(VND)</th>";
                                    htmlcode += "   <th>Original Debt Payable<br /> (VND)</th>";
                                    htmlcode += " </tr>";
                                    htmlcode += "<tr>";
                                    htmlcode += "  <td></td>";
                                    htmlcode += " <td>";
                                    htmlcode += "   <p style='text-align: center;'>" + number_format(temp, 0, ".", ",") + "</p>'";
                                    htmlcode += " </td>";
                                    htmlcode += " <td></td>";
                                    htmlcode += " <td></td>";
                                    htmlcode += "    <td></td>";
                                    htmlcode += "  </tr>";

                                    for (j = 1; j <= val_month * 12; j++) {
                                        interest_payment = temp * (item.InterestVND / 100 / 12);
                                        temp = ((1 + (item.InterestVND / 100 / 12))) * temp - (ba / total);
                                        debit_payment = (ba / total) - interest_payment;
                                        totaltemp += temp;
                                        totaldebit_payment += debit_payment;
                                        totalinterest_payment += interest_payment;
                                        htmlcode += "<tr>";
                                        htmlcode += " <td>";
                                        htmlcode += "     <p style='text-align: center;'>" + j + "</p>";
                                        htmlcode += " </td>";
                                        htmlcode += "  <td>";
                                        if (temp >= 1) {
                                            htmlcode += "     <p style='text-align: center;'>" + number_format(temp, 0, ".", ",") + "</p>";
                                        }
                                        else {
                                            htmlcode += "     <p style='text-align: center;'>0</p>";
                                        }
                                        htmlcode += "  </td>";
                                        htmlcode += " <td>";
                                        htmlcode += "     <p style='text-align: center;'>" + number_format(ba / total, 0, ".", ",") + "</p>";
                                        htmlcode += "  </td>";
                                        htmlcode += " <td>";
                                        htmlcode += "      <p style='text-align: center;'>" + number_format(interest_payment, 0, ".", ",") + "</p>";
                                        htmlcode += "  </td>";
                                        htmlcode += "  <td>";
                                        htmlcode += "      <p style='text-align: center;'>" + number_format(debit_payment, 0, ".", ",") + "</p>";
                                        htmlcode += "   </td>";
                                        htmlcode += "   </tr>";
                                    }
                                    htmlcode += " <tr>";
                                    htmlcode += "    <td colspan='2'>";
                                    htmlcode += "         <p style='text-align: center;'>Total</p>";
                                    htmlcode += "    </td>";
                                    htmlcode += "   <td>";
                                    htmlcode += "       <p style='text-align: center;'>" + number_format((ba / total) * val_month * 12, 0, ".", ",") + "</p>";
                                    htmlcode += "  </td>";
                                    htmlcode += "  <td>";
                                    htmlcode += "       <p style='text-align: center;'>" + number_format(totalinterest_payment, 0, ".", ",") + "</p>";
                                    htmlcode += "   </td>";
                                    htmlcode += "  <td>";
                                    htmlcode += "       <p style='text-align: center;'>" + number_format(totaldebit_payment, 0, ".", ",") + "</p>";
                                    htmlcode += "  </td>";
                                    htmlcode += " </tr>";
                                    htmlcode += "  </table>";
                                    htmlcode += "  </td>";
                                    htmlcode += "  </tr>";
                                    temp = ba;
                                    interest_payment = 0;
                                    debit_payment = 0;
                                    totaltemp = 0;
                                    totalinterest_payment = 0;
                                    totaldebit_payment = 0;
                                });
                            }


                            $("#product-table tbody").html("");
                            $("#product-table tbody").append(htmlcode);
                            $("#product-table").trigger("update");
                            $('tbody > tr:visible').removeClass('odd even').filter(':even').addClass('odd').end().filter(':odd').addClass('even');
                            $(".table-loan-payment").fancybox({
                                wrapCSS: 'fancybox-custom',
                                closeClick: true,
                                openEffect: 'elastic',
                                closeEffect: 'elastic',
                                helpers: {
                                    title: {
                                        type: 'float'
                                    }
                                }
                            });
                        }
                        else {

                            htmlcode = "<tr><td colspan='6' style='margin-top: 10px;font-weight: bold;text-align: center;margin-bottom: 10px;'>No result</p></td></tr>";
                            $("#product-table tbody").html(htmlcode);
                        }
                    }
                });
            });
            $("#years-homeequityloan").change(function () {
                var a = $(this).val();
                $("#slider_year").slider("value", $(this).val());
                var max = $("#slider_year").slider("option", "max");
                var min = $("#slider_year").slider("option", "min");
                $("#slider_year").slider("value", $(this).val());
                if (a > max) {
                    $("#years-homeequityloan").val($("#slider_year").slider("option", "max"));
                }
                if (a < min) {
                    $("#years-homeequityloan").val($("#slider_year").slider("option", "min"));
                }
                var AppUrl = $("#AppUrl").text();
                var val = $("#amount-homeequityloan").val().replace(",", "").replace(",", "").replace(",", "");;
                var val_cate = $("#rel_cate").attr("rel");
                var val_month = $("#years-homeequityloan").val();
                var ba = parseFloat(val);
                var temp = ba;
                var interest_payment = 0;
                var debit_payment = 0;
                var totaltemp = 0;
                var totalinterest_payment = 0;
                var totaldebit_payment = 0;
                var totalmonthlypayment = 0;
                var monthlypayment = 0;
                $.ajax({
                    type: "post",
                    url: AppUrl + "/HomeEquityLoan/getHomeEquityLoan",
                    data: { planid: val_cate, balance: ba, years: val_month },
                    dataType: "json",
                    success: function (rvdata) {
                        var htmlcode = "";
                        if (rvdata.length > 0) {

                            if (val_cate == 1) {
                                $(rvdata).each(function (index, item) {
                                    htmlcode += "<tr>";
                                    htmlcode += " <td class='td-bank-saving'>";
                                    htmlcode += " <a title='View Detail' href='" + AppUrl + "/home-equity-loan/" + convertounsign(item.CompanyName).toLowerCase() + "/" + convertounsign(item.HomeEquityLoanName).toLowerCase() + "/" + item.HomeEquityLoanID + "'><img alt='' src='/Content/UpLoad/Images/" + item.CompanyImg + "' /></a>";
                                    htmlcode += "<p class='bank-title'><a title='" + item.CompanyName + "' href='" + AppUrl + "/home-equity-loan/" + convertounsign(item.CompanyName).toLowerCase() + "/" + item.CompanyID + "'>" + item.CompanyName + "</a>" + item.HomeEquityLoanName + "</p>";
                                    htmlcode += " </td>";
                                    htmlcode += " <td style='vertical-align:middle;'>";
                                    htmlcode += "	<p style='text-align:center;'>" + item.MaximumBalance.replace(".", ",").replace(".", ",").replace(".", ",") + "</p>";
                                    htmlcode += "</td>";
                                    htmlcode += " <td style='vertical-align: middle;'>";
                                    htmlcode += " <p style='text-align: center;'>" + val_month + " Year</p>";
                                    htmlcode += "  </td>";
                                    if (item.InterestVND != 0) {
                                        htmlcode += " <td style='vertical-align:middle;'>";
                                        htmlcode += "<p class='highlight-blue text-p'>" + item.InterestVND + " %</p>";
                                        htmlcode += " </td>";
                                        htmlcode += " <td style='vertical-align:middle;'>";
                                        htmlcode += " <a href='#table-" + convertounsign(item.HomeEquityLoanName) + "-" + item.HomeEquityLoanID + "' title='Reference repayment schedule' id='tableloanpayment-" + item.HomeEquityLoanID + "'  class='table-loan-payment'>Reference repayment schedule</a>";
                                        htmlcode += " </td>";
                                    }
                                    else {
                                        htmlcode += " <td style='vertical-align:middle;' colspan='2'>";
                                        htmlcode += "<p class='highlight-blue-1 text-p'>Please kindly click on \"Apply\" button to contact us</p>";
                                        htmlcode += " </td>";
                                    }
                                    htmlcode += " <td class='td-btn'>";
                                    htmlcode += "	<a class='btn-app' href='" + AppUrl + "/home-equity-loan/apply/" + item.HomeEquityLoanID + "'>Apply >></a>";
                                    htmlcode += "<a href='#" + convertounsign(item.HomeEquityLoanName.toLowerCase()) + "-" + item.HomeEquityLoanID + "' class='more-link' onclick='return viewmore(this)' title='More Info'>More Info</a>";
                                    htmlcode += "</td>";
                                    htmlcode += " </tr>";
                                    htmlcode += "<tr id='" + convertounsign(item.HomeEquityLoanName.toLowerCase()) + "-" + item.HomeEquityLoanID + "' class='more-info' style='display: none;'>";
                                    htmlcode += "<td colspan='6'>";
                                    htmlcode += " <div class='more-info-top' >";
                                    htmlcode += " <div class='more-info-wrapper'>";
                                    htmlcode += "<h4>Benefit & Feature</h4>";
                                    htmlcode += "<div class='item-list'>";
                                    htmlcode += item.Benefit;
                                    htmlcode += "</div>";
                                    htmlcode += "</div>";
                                    htmlcode += "<div class='more-info-wrapper'>";
                                    htmlcode += "<h4>Fees</h4>";
                                    htmlcode += " <div class='item-list'>";
                                    htmlcode += item.FeeContent;
                                    htmlcode += "</div>";
                                    htmlcode += " </div>";
                                    htmlcode += "<div class='more-info-wrapper'>";
                                    htmlcode += "<h4>More Infomation</h4>";
                                    htmlcode += " <div class='item-list'>";
                                    htmlcode += item.MoreInfo;
                                    htmlcode += "</div>  ";
                                    htmlcode += " </div>";
                                    htmlcode += "</div>";
                                    htmlcode += "</td>";
                                    htmlcode += "</tr>";

                                    htmlcode += "    <tr  id='table-" + convertounsign(item.HomeEquityLoanName) + "-" + item.HomeEquityLoanID + "' style='display:none;'>";
                                    htmlcode += "<td>";
                                    htmlcode += "   <table class='product-table-loan'>";
                                    htmlcode += "   <tr>";
                                    htmlcode += "   <th style='width: 10%'>Month</th>";
                                    htmlcode += " <th>Outstanding Principal<br />(VND)</th>";
                                    htmlcode += "  <th>Monthly Payable <br />(VND)</th>";
                                    htmlcode += "  <th>Interest Payable <br />(VND)</th>";
                                    htmlcode += "   <th>Original Debt Payable<br /> (VND)</th>";
                                    htmlcode += " </tr>";
                                    htmlcode += "<tr>";
                                    htmlcode += "  <td></td>";
                                    htmlcode += " <td>";
                                    htmlcode += "   <p style='text-align: center;'>" + number_format(temp, 0, ".", ",") + "</p>'";
                                    htmlcode += " </td>";
                                    htmlcode += " <td></td>";
                                    htmlcode += " <td></td>";
                                    htmlcode += "    <td></td>";
                                    htmlcode += "  </tr>";

                                    for (j = 1; j <= val_month * 12; j++) {
                                        interest_payment = temp * (item.InterestVND / 100 / 12);
                                        debit_payment = ba / (val_month * 12);
                                        temp = temp - debit_payment;
                                        monthlypayment = interest_payment + debit_payment;
                                        totalmonthlypayment += monthlypayment;
                                        totaltemp += temp;
                                        totaldebit_payment += debit_payment;
                                        totalinterest_payment += interest_payment;
                                        htmlcode += "<tr>";
                                        htmlcode += " <td>";
                                        htmlcode += "     <p style='text-align: center;'>" + j + "</p>";
                                        htmlcode += " </td>";
                                        htmlcode += "  <td>";
                                        if (temp >= 1) {
                                            htmlcode += "     <p style='text-align: center;'>" + number_format(temp, 0, ".", ",") + "</p>";
                                        }
                                        else {
                                            htmlcode += "     <p style='text-align: center;'>0</p>";
                                        }
                                        htmlcode += "  </td>";
                                        htmlcode += " <td>";
                                        htmlcode += "     <p style='text-align: center;'>" + number_format(monthlypayment, 0, ".", ",") + "</p>";
                                        htmlcode += "  </td>";
                                        htmlcode += " <td>";
                                        htmlcode += "      <p style='text-align: center;'>" + number_format(interest_payment, 0, ".", ",") + "</p>";
                                        htmlcode += "  </td>";
                                        htmlcode += "  <td>";
                                        htmlcode += "      <p style='text-align: center;'>" + number_format(debit_payment, 0, ".", ",") + "</p>";
                                        htmlcode += "   </td>";
                                        htmlcode += "   </tr>";
                                    }
                                    htmlcode += " <tr>";
                                    htmlcode += "    <td colspan='2'>";
                                    htmlcode += "         <p style='text-align: center;'>Total</p>";
                                    htmlcode += "    </td>";
                                    htmlcode += "   <td>";
                                    htmlcode += "       <p style='text-align: center;'>" + number_format(totalmonthlypayment, 0, ".", ",") + "</p>";
                                    htmlcode += "  </td>";
                                    htmlcode += "  <td>";
                                    htmlcode += "       <p style='text-align: center;'>" + number_format(totalinterest_payment, 0, ".", ",") + "</p>";
                                    htmlcode += "   </td>";
                                    htmlcode += "  <td>";
                                    htmlcode += "       <p style='text-align: center;'>" + number_format(totaldebit_payment, 0, ".", ",") + "</p>";
                                    htmlcode += "  </td>";
                                    htmlcode += " </tr>";
                                    htmlcode += "  </table>";
                                    htmlcode += "  </td>";
                                    htmlcode += "  </tr>";
                                    temp = ba;
                                    interest_payment = 0;
                                    debit_payment = 0;
                                    totaltemp = 0;
                                    totalinterest_payment = 0;
                                    totaldebit_payment = 0;
                                    monthlypayment = 0;
                                    totalmonthlypayment = 0;
                                });
                            }
                            else {
                                var payment = 0;
                                $(rvdata).each(function (index, item) {
                                    var total = 0;
                                    for (i = 1; i <= val_month * 12; i++) {
                                        total += Math.pow((1 + (item.InterestVND / 100 / 12)), -i);
                                    }
                                    htmlcode += "<tr>";
                                    htmlcode += " <td class='td-bank-saving'>";
                                    htmlcode += " <a title='Xem chi tiết' href='" + AppUrl + "/home-equity-loan/" + convertounsign(item.CompanyName).toLowerCase() + "/" + convertounsign(item.HomeEquityLoanName).toLowerCase() + "/" + item.HomeEquityLoanID + "'><img alt='' src='/Content/UpLoad/Images/" + item.CompanyImg + "' /></a>";
                                    htmlcode += "<p class='bank-title'><a title='" + item.CompanyName + "' href='" + AppUrl + "/home-equity-loan/" + convertounsign(item.CompanyName).toLowerCase() + "/" + item.CompanyID + "'>" + item.CompanyName + "</a>" + item.HomeEquityLoanName + "</p>";
                                    htmlcode += " </td>";
                                    htmlcode += " <td style='vertical-align:middle;'>";
                                    htmlcode += "	<p style='text-align:center;'>" + item.MaximumBalance.replace(".", ",").replace(".", ",").replace(".", ",") + "</p>";
                                    htmlcode += "</td>";
                                    htmlcode += " <td style='vertical-align: middle;'>";
                                    htmlcode += " <p style='text-align: center;'>" + val_month + " Year</p>";
                                    htmlcode += "  </td>";
                                    if (item.InterestVND != 0) {
                                        htmlcode += " <td style='vertical-align:middle;'>";
                                        htmlcode += "<p class='highlight-blue text-p'>" + item.InterestVND + " %</p>";
                                        htmlcode += " </td>";
                                        htmlcode += " <td style='vertical-align:middle;'>";
                                        htmlcode += "<p class='highlight-blue text-p'>" + number_format(ba / total, 0, ".", ",") + "</p>";
                                        htmlcode += " <a href='#table-" + convertounsign(item.HomeEquityLoanName) + "-" + item.HomeEquityLoanID + "' title='Reference repayment schedule' id='tableloanpayment-" + item.HomeEquityLoanID + "'  class='table-loan-payment'>Reference repayment schedule</a>";
                                        htmlcode += " </td>";
                                    }
                                    else {
                                        htmlcode += " <td style='vertical-align:middle;' colspan='2'>";
                                        htmlcode += "<p class='highlight-blue-1 text-p'>Please kindly click on \"Apply\" button to contact us</p>";
                                        htmlcode += " </td>";
                                    }
                                    htmlcode += " <td class='td-btn'>";
                                    htmlcode += "	<a class='btn-app' href='" + AppUrl + "/home-equity-loan/apply/" + item.HomeEquityLoanID + "'>Apply >></a>";
                                    htmlcode += "<a href='#" + convertounsign(item.HomeEquityLoanName.toLowerCase()) + "-" + item.HomeEquityLoanID + "' class='more-link' onclick='return viewmore(this)' title='More Info'>More Info</a>";
                                    htmlcode += "</td>";
                                    htmlcode += " </tr>";
                                    htmlcode += "<tr id='" + convertounsign(item.HomeEquityLoanName.toLowerCase()) + "-" + item.HomeEquityLoanID + "' class='more-info' style='display: none;'>";
                                    htmlcode += "<td colspan='6'>";
                                    htmlcode += " <div class='more-info-top' >";
                                    htmlcode += " <div class='more-info-wrapper'>";
                                    htmlcode += "<h4>Benefit & Feature</h4>";
                                    htmlcode += "<div class='item-list'>";
                                    htmlcode += item.Benefit;
                                    htmlcode += "</div>";
                                    htmlcode += "</div>";
                                    htmlcode += "<div class='more-info-wrapper'>";
                                    htmlcode += "<h4>Fees</h4>";
                                    htmlcode += " <div class='item-list'>";
                                    htmlcode += item.FeeContent;
                                    htmlcode += "</div>";
                                    htmlcode += " </div>";
                                    htmlcode += "<div class='more-info-wrapper'>";
                                    htmlcode += "<h4>More Infomation</h4>";
                                    htmlcode += " <div class='item-list'>";
                                    htmlcode += item.MoreInfo;
                                    htmlcode += "</div>  ";
                                    htmlcode += " </div>";
                                    htmlcode += "</div>";
                                    htmlcode += "</td>";
                                    htmlcode += "</tr>";
                                    htmlcode += "    <tr  id='table-" + convertounsign(item.HomeEquityLoanName) + "-" + item.HomeEquityLoanID + "' style='display:none;'>";
                                    htmlcode += "<td>";
                                    htmlcode += "   <table class='product-table-loan'>";
                                    htmlcode += "   <tr>";
                                    htmlcode += "   <th style='width: 10%'>Month</th>";
                                    htmlcode += " <th>Outstanding Principal<br />(VND)</th>";
                                    htmlcode += "  <th>Monthly Payable <br />(VND)</th>";
                                    htmlcode += "  <th>Interest Payable <br />(VND)</th>";
                                    htmlcode += "   <th>Original Debt Payable<br /> (VND)</th>";
                                    htmlcode += " </tr>";
                                    htmlcode += "<tr>";
                                    htmlcode += "  <td></td>";
                                    htmlcode += " <td>";
                                    htmlcode += "   <p style='text-align: center;'>" + number_format(temp, 0, ".", ",") + "</p>'";
                                    htmlcode += " </td>";
                                    htmlcode += " <td></td>";
                                    htmlcode += " <td></td>";
                                    htmlcode += "    <td></td>";
                                    htmlcode += "  </tr>";

                                    for (j = 1; j <= val_month * 12; j++) {
                                        interest_payment = temp * (item.InterestVND / 100 / 12);
                                        temp = ((1 + (item.InterestVND / 100 / 12))) * temp - (ba / total);
                                        debit_payment = (ba / total) - interest_payment;
                                        totaltemp += temp;
                                        totaldebit_payment += debit_payment;
                                        totalinterest_payment += interest_payment;
                                        htmlcode += "<tr>";
                                        htmlcode += " <td>";
                                        htmlcode += "     <p style='text-align: center;'>" + j + "</p>";
                                        htmlcode += " </td>";
                                        htmlcode += "  <td>";
                                        if (temp >= 1) {
                                            htmlcode += "     <p style='text-align: center;'>" + number_format(temp, 0, ".", ",") + "</p>";
                                        }
                                        else {
                                            htmlcode += "     <p style='text-align: center;'>0</p>";
                                        }
                                        htmlcode += "  </td>";
                                        htmlcode += " <td>";
                                        htmlcode += "     <p style='text-align: center;'>" + number_format(ba / total, 0, ".", ",") + "</p>";
                                        htmlcode += "  </td>";
                                        htmlcode += " <td>";
                                        htmlcode += "      <p style='text-align: center;'>" + number_format(interest_payment, 0, ".", ",") + "</p>";
                                        htmlcode += "  </td>";
                                        htmlcode += "  <td>";
                                        htmlcode += "      <p style='text-align: center;'>" + number_format(debit_payment, 0, ".", ",") + "</p>";
                                        htmlcode += "   </td>";
                                        htmlcode += "   </tr>";
                                    }
                                    htmlcode += " <tr>";
                                    htmlcode += "    <td colspan='2'>";
                                    htmlcode += "         <p style='text-align: center;'>Total</p>";
                                    htmlcode += "    </td>";
                                    htmlcode += "   <td>";
                                    htmlcode += "       <p style='text-align: center;'>" + number_format((ba / total) * val_month * 12, 0, ".", ",") + "</p>";
                                    htmlcode += "  </td>";
                                    htmlcode += "  <td>";
                                    htmlcode += "       <p style='text-align: center;'>" + number_format(totalinterest_payment, 0, ".", ",") + "</p>";
                                    htmlcode += "   </td>";
                                    htmlcode += "  <td>";
                                    htmlcode += "       <p style='text-align: center;'>" + number_format(totaldebit_payment, 0, ".", ",") + "</p>";
                                    htmlcode += "  </td>";
                                    htmlcode += " </tr>";
                                    htmlcode += "  </table>";
                                    htmlcode += "  </td>";
                                    htmlcode += "  </tr>";
                                    temp = ba;
                                    interest_payment = 0;
                                    debit_payment = 0;
                                    totaltemp = 0;
                                    totalinterest_payment = 0;
                                    totaldebit_payment = 0;
                                });
                            }


                            $("#product-table tbody").html("");
                            $("#product-table tbody").append(htmlcode);
                            $("#product-table").trigger("update");
                            $('tbody > tr:visible').removeClass('odd even').filter(':even').addClass('odd').end().filter(':odd').addClass('even');
                            $(".table-loan-payment").fancybox({
                                wrapCSS: 'fancybox-custom',
                                closeClick: true,
                                openEffect: 'elastic',
                                closeEffect: 'elastic',
                                helpers: {
                                    title: {
                                        type: 'float'
                                    }
                                }
                            });
                        }
                        else {

                            htmlcode = "<tr><td colspan='6' style='margin-top: 10px;font-weight: bold;text-align: center;margin-bottom: 10px;'>No result</p></td></tr>";
                            $("#product-table tbody").html(htmlcode);
                        }
                    }
                });
            });
        }
        $(".table-loan-payment").fancybox({
            wrapCSS: 'fancybox-custom',
            closeClick: true,
            openEffect: 'elastic',
            closeEffect: 'elastic',
            helpers: {
                title: {
                    type: 'float'
                }
            }

        });
    });
    function number_format(number, decimals, dec_point, thousands_sep) {

        var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals;
        var d = dec_point == undefined ? "," : dec_point;
        var t = thousands_sep == undefined ? "." : thousands_sep, s = n < 0 ? "-" : "";
        var i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;

        return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
    }
    function convertounsign(str) {
        str = str.toLowerCase();
        str = str.replace(/à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ/g, "a");
        str = str.replace(/è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ/g, "e");
        str = str.replace(/ì|í|ị|ỉ|ĩ/g, "i");
        str = str.replace(/ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ/g, "o");
        str = str.replace(/ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ/g, "u");
        str = str.replace(/ỳ|ý|ỵ|ỷ|ỹ/g, "y");
        str = str.replace(/đ/g, "d");
        str = str.replace(/!|%|\^|\*|\(|\)|\+|\=|\<|\>|\?|\/|,|\.|\:|\;|\'| |\"|\&|\#|\[|\]|~|$|_/g, "-");
        /* tìm và thay thế các kí tự đặc biệt trong chuỗi sang kí tự - */
        str = str.replace(/-+-/g, "-"); //thay thế 2- thành 1- 
        str = str.replace(/^\-+|\-+$/g, "");
        //cắt bỏ ký tự - ở đầu và cuối chuỗi  
        return str;
    }
    $(function () {
        var val = 0;
        var lang = $("#CurrentLangCode").html();
        if (lang == "vi-VN") {
            $("#slider_amount").slider({
                value: 50000000,
                min: 10000000,
                max: 10000000000,
                step: 5000000,
                slide: function (event, ui) {
                    $("#amount-homeequityloan").val(number_format(ui.value, 0, ",", "."));

                    var AppUrl = $("#AppUrl").text();
                    val = $("#amount-homeequityloan").val().replace(".", "").replace(".", "").replace(".", "");
                    var val_cate = $("#rel_cate").attr("rel");
                    var val_month = $("#years-homeequityloan").val();
                    var ba = parseFloat(val);
                    var temp = ba;
                    var interest_payment = 0;
                    var debit_payment = 0;
                    var totaltemp = 0;
                    var totalinterest_payment = 0;
                    var totaldebit_payment = 0;
                    var totalmonthlypayment = 0;
                    var monthlypayment = 0;
                    $.ajax({
                        type: "post",
                        url: AppUrl + "/HomeEquityLoan/getHomeEquityLoan",
                        data: { planid: val_cate, balance: ba, years: val_month },
                        dataType: "json",
                        success: function (rvdata) {
                            var htmlcode = "";
                            if (rvdata.length > 0) {
                                if (val_cate == 1) {
                                    $(rvdata).each(function (index, item) {
                                        htmlcode += "<tr>";
                                        htmlcode += " <td class='td-bank-saving'>";
                                        htmlcode += " <a title='Xem chi tiết' href='" + AppUrl + "/home-equity-loan/" + convertounsign(item.CompanyName).toLowerCase() + "/" + convertounsign(item.HomeEquityLoanName).toLowerCase() + "/" + item.HomeEquityLoanID + "'><img alt='' src='/Content/UpLoad/Images/" + item.CompanyImg + "' /></a>";
                                        htmlcode += "<p class='bank-title'><a title='" + item.CompanyName + "' href='" + AppUrl + "/home-equity-loan/" + convertounsign(item.CompanyName).toLowerCase() + "/" + item.CompanyID + "'>" + item.CompanyName + "</a>" + item.HomeEquityLoanName + "</p>";
                                        htmlcode += " </td>";
                                        htmlcode += " <td style='vertical-align:middle;'>";
                                        htmlcode += "	<p style='text-align:center;'>" + item.MaximumBalance + "</p>";
                                        htmlcode += "</td>";
                                        htmlcode += " <td style='vertical-align: middle;'>";
                                        htmlcode += " <p style='text-align: center;'>" + val_month + " Năm</p>";
                                        htmlcode += "  </td>";
                                        if (item.InterestVND != 0) {
                                            htmlcode += " <td style='vertical-align:middle;'>";
                                            htmlcode += "<p class='highlight-blue text-p'>" + item.InterestVND.toString().replace(".", ",") + " %</p>";
                                            htmlcode += " </td>";
                                            htmlcode += " <td style='vertical-align:middle;'>";
                                            htmlcode += " <a href='#table-" + convertounsign(item.HomeEquityLoanName) + "-" + item.HomeEquityLoanID + "' title='Lịch biểu trả nợ tham khảo' id='tableloanpayment-" + item.HomeEquityLoanID + "' class='table-loan-payment'>Lịch biểu trả nợ tham khảo</a>";
                                            htmlcode += " </td>";
                                        }
                                        else {
                                            htmlcode += " <td style='vertical-align:middle;' colspan='2'>";
                                            htmlcode += "<p class='highlight-blue-1 text-p'>Vui lòng nhấp vào nút tham gia để liên hệ với chúng tôi</p>";
                                            htmlcode += " </td>";
                                        }
                                        htmlcode += " <td class='td-btn'>";
                                        htmlcode += "	<a class='btn-app' href='" + AppUrl + "/home-equity-loan/apply/" + item.HomeEquityLoanID + "'>Tham gia >></a>";
                                        htmlcode += "<a href='#" + convertounsign(item.HomeEquityLoanName.toLowerCase()) + "-" + item.HomeEquityLoanID + "' class='more-link' onclick='return viewmore(this)' title='Xem thêm'>Xem thêm</a>";
                                        htmlcode += "</td>";
                                        htmlcode += " </tr>";
                                        htmlcode += "<tr id='" + convertounsign(item.HomeEquityLoanName.toLowerCase()) + "-" + item.HomeEquityLoanID + "' class='more-info' style='display: none;'>";
                                        htmlcode += "<td colspan='6'>";
                                        htmlcode += " <div class='more-info-top' >";
                                        htmlcode += " <div class='more-info-wrapper'>";
                                        htmlcode += "<h4>Quyền lợi & Tính năng</h4>";
                                        htmlcode += "<div class='item-list'>";
                                        htmlcode += item.Benefit;
                                        htmlcode += "</div>";
                                        htmlcode += "</div>";
                                        htmlcode += "<div class='more-info-wrapper'>";
                                        htmlcode += "<h4>Chi phí</h4>";
                                        htmlcode += " <div class='item-list'>";
                                        htmlcode += item.FeeContent;
                                        htmlcode += "</div>";
                                        htmlcode += " </div>";
                                        htmlcode += "<div class='more-info-wrapper'>";
                                        htmlcode += "<h4>Thông tin thêm</h4>";
                                        htmlcode += " <div class='item-list'>";
                                        htmlcode += item.MoreInfo;
                                        htmlcode += "</div>  ";
                                        htmlcode += " </div>";
                                        htmlcode += "</div>";
                                        htmlcode += "</td>";
                                        htmlcode += "</tr>";

                                        htmlcode += "    <tr  id='table-" + convertounsign(item.HomeEquityLoanName) + "-" + item.HomeEquityLoanID + "' style='display:none;'>";
                                        htmlcode += "<td>";
                                        htmlcode += "   <table class='product-table-loan'>";
                                        htmlcode += "   <tr>";
                                        htmlcode += "   <th style='width: 10%'>Tháng</th>";
                                        htmlcode += " <th>Khoảng dư nợ gốc<br />(VND)</th>";
                                        htmlcode += "  <th>Khoảng phải trả hàng tháng<br />(VND)</th>";
                                        htmlcode += "  <th>Lãi phải trả<br />(VND)</th>";
                                        htmlcode += "   <th>Nợ gốc phải trả<br /> (VND)</th>";
                                        htmlcode += " </tr>";
                                        htmlcode += "<tr>";
                                        htmlcode += "  <td></td>";
                                        htmlcode += " <td>";
                                        htmlcode += "   <p style='text-align: center;'>" + number_format(temp, 0, ",", ".") + "</p>'";
                                        htmlcode += " </td>";
                                        htmlcode += " <td></td>";
                                        htmlcode += " <td></td>";
                                        htmlcode += "    <td></td>";
                                        htmlcode += "  </tr>";

                                        for (j = 1; j <= val_month * 12; j++) {
                                            interest_payment = temp * (item.InterestVND / 100 / 12);
                                            debit_payment = ba / (val_month * 12);
                                            temp = temp - debit_payment;
                                            monthlypayment = interest_payment + debit_payment;
                                            totalmonthlypayment += monthlypayment;
                                            totaltemp += temp;
                                            totaldebit_payment += debit_payment;
                                            totalinterest_payment += interest_payment;
                                            htmlcode += "<tr>";
                                            htmlcode += " <td>";
                                            htmlcode += "     <p style='text-align: center;'>" + j + "</p>";
                                            htmlcode += " </td>";
                                            htmlcode += "  <td>";
                                            if (temp >= 1) {
                                                htmlcode += "     <p style='text-align: center;'>" + number_format(temp, 0, ",", ".") + "</p>";
                                            }
                                            else {
                                                htmlcode += "     <p style='text-align: center;'>0</p>";
                                            }
                                            htmlcode += "  </td>";
                                            htmlcode += " <td>";
                                            htmlcode += "     <p style='text-align: center;'>" + number_format(monthlypayment, 0, ",", ".") + "</p>";
                                            htmlcode += "  </td>";
                                            htmlcode += " <td>";
                                            htmlcode += "      <p style='text-align: center;'>" + number_format(interest_payment, 0, ",", ".") + "</p>";
                                            htmlcode += "  </td>";
                                            htmlcode += "  <td>";
                                            htmlcode += "      <p style='text-align: center;'>" + number_format(debit_payment, 0, ",", ".") + "</p>";
                                            htmlcode += "   </td>";
                                            htmlcode += "   </tr>";
                                        }
                                        htmlcode += " <tr>";
                                        htmlcode += "    <td colspan='2'>";
                                        htmlcode += "         <p style='text-align: center;'>Tổng</p>";
                                        htmlcode += "    </td>";
                                        htmlcode += "   <td>";
                                        htmlcode += "       <p style='text-align: center;'>" + number_format(totalmonthlypayment, 0, ",", ".") + "</p>";
                                        htmlcode += "  </td>";
                                        htmlcode += "  <td>";
                                        htmlcode += "       <p style='text-align: center;'>" + number_format(totalinterest_payment, 0, ",", ".") + "</p>";
                                        htmlcode += "   </td>";
                                        htmlcode += "  <td>";
                                        htmlcode += "       <p style='text-align: center;'>" + number_format(totaldebit_payment, 0, ",", ".") + "</p>";
                                        htmlcode += "  </td>";
                                        htmlcode += " </tr>";
                                        htmlcode += "  </table>";
                                        htmlcode += "  </td>";
                                        htmlcode += "  </tr>";
                                        temp = ba;
                                        interest_payment = 0;
                                        debit_payment = 0;
                                        totaltemp = 0;
                                        totalinterest_payment = 0;
                                        totaldebit_payment = 0;
                                        monthlypayment = 0;
                                        totalmonthlypayment = 0;
                                    });
                                }
                                else {
                                    var payment = 0;
                                    $(rvdata).each(function (index, item) {
                                        var total = 0;
                                        for (i = 1; i <= val_month * 12; i++) {
                                            total += Math.pow((1 + (item.InterestVND / 100 / 12)), -i);
                                        }
                                        htmlcode += "<tr>";
                                        htmlcode += " <td class='td-bank-saving'>";
                                        htmlcode += " <a title='Xem chi tiết' href='" + AppUrl + "/home-equity-loan/" + convertounsign(item.CompanyName).toLowerCase() + "/" + convertounsign(item.HomeEquityLoanName).toLowerCase() + "/" + item.HomeEquityLoanID + "'><img alt='' src='/Content/UpLoad/Images/" + item.CompanyImg + "' /></a>";
                                        htmlcode += "<p class='bank-title'><a title='" + item.CompanyName + "' href='" + AppUrl + "/home-equity-loan/" + convertounsign(item.CompanyName).toLowerCase() + "/" + item.CompanyID + "'>" + item.CompanyName + "</a>" + item.HomeEquityLoanName + "</p>";
                                        htmlcode += " </td>";
                                        htmlcode += " <td style='vertical-align:middle;'>";
                                        htmlcode += "	<p style='text-align:center;'>" + item.MaximumBalance + "</p>";
                                        htmlcode += "</td>";
                                        htmlcode += " <td style='vertical-align: middle;'>";
                                        htmlcode += " <p style='text-align: center;'>" + val_month + " Năm</p>";
                                        htmlcode += "  </td>";
                                        if (item.InterestVND != 0) {
                                            htmlcode += " <td style='vertical-align:middle;'>";
                                            htmlcode += "<p class='highlight-blue text-p'>" + item.InterestVND.toString().replace(".", ",") + " %</p>";
                                            htmlcode += " </td>";
                                            htmlcode += " <td style='vertical-align:middle;'>";
                                            htmlcode += "<p class='highlight-blue text-p'>" + number_format(ba / total, 0, ",", ".") + "</p>";
                                            htmlcode += " <a href='#table-" + convertounsign(item.HomeEquityLoanName) + "-" + item.HomeEquityLoanID + "' title='Lịch biểu trả nợ tham khảo' id='tableloanpayment-" + item.HomeEquityLoanID + "'  class='table-loan-payment'>Lịch biểu trả nợ tham khảo</a>";
                                            htmlcode += " </td>";
                                        }
                                        else {
                                            htmlcode += " <td style='vertical-align:middle;' colspan='2'>";
                                            htmlcode += "<p class='highlight-blue-1 text-p'>Vui lòng nhấp vào nút tham gia để liên hệ với chúng tôi</p>";
                                            htmlcode += " </td>";
                                        }
                                        htmlcode += " <td class='td-btn'>";
                                        htmlcode += "	<a class='btn-app' href='" + AppUrl + "/home-equity-loan/apply/" + item.HomeEquityLoanID + "'>Tham gia >></a>";
                                        htmlcode += "<a href='#" + convertounsign(item.HomeEquityLoanName.toLowerCase()) + "-" + item.HomeEquityLoanID + "' class='more-link' onclick='return viewmore(this)' title='Xem thêm'>Xem thêm</a>";
                                        htmlcode += "</td>";
                                        htmlcode += " </tr>";
                                        htmlcode += "<tr id='" + convertounsign(item.HomeEquityLoanName.toLowerCase()) + "-" + item.HomeEquityLoanID + "' class='more-info' style='display: none;'>";
                                        htmlcode += "<td colspan='6'>";
                                        htmlcode += " <div class='more-info-top' >";
                                        htmlcode += " <div class='more-info-wrapper'>";
                                        htmlcode += "<h4>Quyền lợi & Tính năng</h4>";
                                        htmlcode += "<div class='item-list'>";
                                        htmlcode += item.Benefit;
                                        htmlcode += "</div>";
                                        htmlcode += "</div>";
                                        htmlcode += "<div class='more-info-wrapper'>";
                                        htmlcode += "<h4>Chi phí</h4>";
                                        htmlcode += " <div class='item-list'>";
                                        htmlcode += item.FeeContent;
                                        htmlcode += "</div>";
                                        htmlcode += " </div>";
                                        htmlcode += "<div class='more-info-wrapper'>";
                                        htmlcode += "<h4>Thông tin thêm</h4>";
                                        htmlcode += " <div class='item-list'>";
                                        htmlcode += item.MoreInfo;
                                        htmlcode += "</div>  ";
                                        htmlcode += " </div>";
                                        htmlcode += "</div>";
                                        htmlcode += "</td>";
                                        htmlcode += "</tr>";

                                        htmlcode += "    <tr  id='table-" + convertounsign(item.HomeEquityLoanName) + "-" + item.HomeEquityLoanID + "' style='display:none;'>";
                                        htmlcode += "<td>";
                                        htmlcode += "   <table class='product-table-loan'>";
                                        htmlcode += "   <tr>";
                                        htmlcode += "   <th style='width: 10%'>Tháng</th>";
                                        htmlcode += " <th>Khoảng dư nợ gốc<br />(VND)</th>";
                                        htmlcode += "  <th>Khoảng phải trả hàng tháng<br />(VND)</th>";
                                        htmlcode += "  <th>Lãi phải trả<br />(VND)</th>";
                                        htmlcode += "   <th>Nợ gốc phải trả<br /> (VND)</th>";
                                        htmlcode += " </tr>";
                                        htmlcode += "<tr>";
                                        htmlcode += "  <td></td>";
                                        htmlcode += " <td>";
                                        htmlcode += "   <p style='text-align: center;'>" + number_format(temp, 0, ",", ".") + "</p>'";
                                        htmlcode += " </td>";
                                        htmlcode += " <td></td>";
                                        htmlcode += " <td></td>";
                                        htmlcode += "    <td></td>";
                                        htmlcode += "  </tr>";

                                        for (j = 1; j <= val_month * 12; j++) {
                                            interest_payment = temp * (item.InterestVND / 100 / 12);
                                            temp = ((1 + (item.InterestVND / 100 / 12))) * temp - (ba / total);
                                            debit_payment = (ba / total) - interest_payment;
                                            totaltemp += temp;
                                            totaldebit_payment += debit_payment;
                                            totalinterest_payment += interest_payment;
                                            htmlcode += "<tr>";
                                            htmlcode += " <td>";
                                            htmlcode += "     <p style='text-align: center;'>" + j + "</p>";
                                            htmlcode += " </td>";
                                            htmlcode += "  <td>";
                                            if (temp >= 1) {
                                                htmlcode += "     <p style='text-align: center;'>" + number_format(temp, 0, ",", ".") + "</p>";
                                            }
                                            else {
                                                htmlcode += "     <p style='text-align: center;'>0</p>";
                                            }
                                            htmlcode += "  </td>";
                                            htmlcode += " <td>";
                                            htmlcode += "     <p style='text-align: center;'>" + number_format(ba / total, 0, ",", ".") + "</p>";
                                            htmlcode += "  </td>";
                                            htmlcode += " <td>";
                                            htmlcode += "      <p style='text-align: center;'>" + number_format(interest_payment, 0, ",", ".") + "</p>";
                                            htmlcode += "  </td>";
                                            htmlcode += "  <td>";
                                            htmlcode += "      <p style='text-align: center;'>" + number_format(debit_payment, 0, ",", ".") + "</p>";
                                            htmlcode += "   </td>";
                                            htmlcode += "   </tr>";
                                        }
                                        htmlcode += " <tr>";
                                        htmlcode += "    <td colspan='2'>";
                                        htmlcode += "         <p style='text-align: center;'>Tổng</p>";
                                        htmlcode += "    </td>";
                                        htmlcode += "   <td>";
                                        htmlcode += "       <p style='text-align: center;'>" + number_format((ba / total) * val_month * 12, 0, ",", ".") + "</p>";
                                        htmlcode += "  </td>";
                                        htmlcode += "  <td>";
                                        htmlcode += "       <p style='text-align: center;'>" + number_format(totalinterest_payment, 0, ",", ".") + "</p>";
                                        htmlcode += "   </td>";
                                        htmlcode += "  <td>";
                                        htmlcode += "       <p style='text-align: center;'>" + number_format(totaldebit_payment, 0, ",", ".") + "</p>";
                                        htmlcode += "  </td>";
                                        htmlcode += " </tr>";
                                        htmlcode += "  </table>";
                                        htmlcode += "  </td>";
                                        htmlcode += "  </tr>";
                                        temp = ba;
                                        interest_payment = 0;
                                        debit_payment = 0;
                                        totaltemp = 0;
                                        totalinterest_payment = 0;
                                        totaldebit_payment = 0;

                                    });
                                }

                                $("#product-table tbody").html("");
                                $("#product-table tbody").append(htmlcode);
                                $("#product-table").trigger("update");
                                $('tbody > tr:visible').removeClass('odd even').filter(':even').addClass('odd').end().filter(':odd').addClass('even');
                                $(".table-loan-payment").fancybox({
                                    wrapCSS: 'fancybox-custom',
                                    closeClick: true,
                                    openEffect: 'elastic',
                                    closeEffect: 'elastic',
                                    helpers: {
                                        title: {
                                            type: 'float'
                                        }
                                    }
                                });
                            }
                            else {
                                htmlcode = "<tr><td colspan='6' style='margin-top: 10px;font-weight: bold;text-align: center;margin-bottom: 10px;'>Không có dữ liệu phù hợp</p></td></tr>";
                                $("#product-table tbody").html(htmlcode);

                            }
                        }
                    });
                }
            });
            $("#amount-homeequityloan").val(number_format($("#slider_amount").slider("value"), 0, ",", "."));
            val = $("#slider_amount").slider("value");
        }
        else {
            $("#slider_amount").slider({
                value: 50000000,
                min: 10000000,
                max: 10000000000,
                step: 5000000,
                slide: function (event, ui) {
                    $("#amount-homeequityloan").val(number_format(ui.value, 0, ".", ","));

                    var AppUrl = $("#AppUrl").text();
                    val = $("#amount-homeequityloan").val().replace(",", "").replace(",", "").replace(",", "");
                    var val_cate = $("#rel_cate").attr("rel");
                    var val_month = $("#years-homeequityloan").val();
                    var ba = parseFloat(val);
                    var temp = ba;
                    var interest_payment = 0;
                    var debit_payment = 0;
                    var totaltemp = 0;
                    var totalinterest_payment = 0;
                    var totaldebit_payment = 0;
                    var totalmonthlypayment = 0;
                    var monthlypayment = 0;
                    $.ajax({
                        type: "post",
                        url: AppUrl + "/HomeEquityLoan/getHomeEquityLoan",
                        data: { planid: val_cate, balance: ba, years: val_month },
                        dataType: "json",
                        success: function (rvdata) {
                            var htmlcode = "";
                            if (rvdata.length > 0) {

                                if (val_cate == 1) {
                                    $(rvdata).each(function (index, item) {
                                        htmlcode += "<tr>";
                                        htmlcode += " <td class='td-bank-saving'>";
                                        htmlcode += " <a title='View Detail' href='" + AppUrl + "/home-equity-loan/" + convertounsign(item.CompanyName).toLowerCase() + "/" + convertounsign(item.HomeEquityLoanName).toLowerCase() + "/" + item.HomeEquityLoanID + "'><img alt='' src='/Content/UpLoad/Images/" + item.CompanyImg + "' /></a>";
                                        htmlcode += "<p class='bank-title'><a title='" + item.CompanyName + "' href='" + AppUrl + "/home-equity-loan/" + convertounsign(item.CompanyName).toLowerCase() + "/" + item.CompanyID + "'>" + item.CompanyName + "</a>" + item.HomeEquityLoanName + "</p>";
                                        htmlcode += " </td>";
                                        htmlcode += " <td style='vertical-align:middle;'>";
                                        htmlcode += "	<p style='text-align:center;'>" + item.MaximumBalance.replace(".", ",").replace(".", ",").replace(".", ",") + "</p>";
                                        htmlcode += "</td>";
                                        htmlcode += " <td style='vertical-align: middle;'>";
                                        htmlcode += " <p style='text-align: center;'>" + val_month + " Year</p>";
                                        htmlcode += "  </td>";
                                        if (item.InterestVND != 0) {
                                            htmlcode += " <td style='vertical-align:middle;'>";
                                            htmlcode += "<p class='highlight-blue text-p'>" + item.InterestVND + " %</p>";
                                            htmlcode += " </td>";
                                            htmlcode += " <td style='vertical-align:middle;'>";
                                            htmlcode += " <a href='#table-" + convertounsign(item.HomeEquityLoanName) + "-" + item.HomeEquityLoanID + "' title='Reference repayment schedule' id='tableloanpayment-" + item.HomeEquityLoanID + "'  class='table-loan-payment'>Reference repayment schedule</a>";
                                            htmlcode += " </td>";
                                        }
                                        else {
                                            htmlcode += " <td style='vertical-align:middle;' colspan='2'>";
                                            htmlcode += "<p class='highlight-blue-1 text-p'>Please kindly click on \"Apply\" button to contact us</p>";
                                            htmlcode += " </td>";
                                        }
                                        htmlcode += " <td class='td-btn'>";
                                        htmlcode += "	<a class='btn-app' href='" + AppUrl + "/home-equity-loan/apply/" + item.HomeEquityLoanID + "'>Apply >></a>";
                                        htmlcode += "<a href='#" + convertounsign(item.HomeEquityLoanName.toLowerCase()) + "-" + item.HomeEquityLoanID + "' class='more-link' onclick='return viewmore(this)' title='More Info'>More Info</a>";
                                        htmlcode += "</td>";
                                        htmlcode += " </tr>";
                                        htmlcode += "<tr id='" + convertounsign(item.HomeEquityLoanName.toLowerCase()) + "-" + item.HomeEquityLoanID + "' class='more-info' style='display: none;'>";
                                        htmlcode += "<td colspan='6'>";
                                        htmlcode += " <div class='more-info-top' >";
                                        htmlcode += " <div class='more-info-wrapper'>";
                                        htmlcode += "<h4>Benefit & Feature</h4>";
                                        htmlcode += "<div class='item-list'>";
                                        htmlcode += item.Benefit;
                                        htmlcode += "</div>";
                                        htmlcode += "</div>";
                                        htmlcode += "<div class='more-info-wrapper'>";
                                        htmlcode += "<h4>Fees</h4>";
                                        htmlcode += " <div class='item-list'>";
                                        htmlcode += item.FeeContent;
                                        htmlcode += "</div>";
                                        htmlcode += " </div>";
                                        htmlcode += "<div class='more-info-wrapper'>";
                                        htmlcode += "<h4>More Infomation</h4>";
                                        htmlcode += " <div class='item-list'>";
                                        htmlcode += item.MoreInfo;
                                        htmlcode += "</div>  ";
                                        htmlcode += " </div>";
                                        htmlcode += "</div>";
                                        htmlcode += "</td>";
                                        htmlcode += "</tr>";

                                        htmlcode += "    <tr  id='table-" + convertounsign(item.HomeEquityLoanName) + "-" + item.HomeEquityLoanID + "' style='display:none;'>";
                                        htmlcode += "<td>";
                                        htmlcode += "   <table class='product-table-loan'>";
                                        htmlcode += "   <tr>";
                                        htmlcode += "   <th style='width: 10%'>Month</th>";
                                        htmlcode += " <th>Outstanding Principal<br />(VND)</th>";
                                        htmlcode += "  <th>Monthly Payable <br />(VND)</th>";
                                        htmlcode += "  <th>Interest Payable <br />(VND)</th>";
                                        htmlcode += "   <th>Original Debt Payable<br /> (VND)</th>";
                                        htmlcode += " </tr>";
                                        htmlcode += "<tr>";
                                        htmlcode += "  <td></td>";
                                        htmlcode += " <td>";
                                        htmlcode += "   <p style='text-align: center;'>" + number_format(temp, 0, ".", ",") + "</p>'";
                                        htmlcode += " </td>";
                                        htmlcode += " <td></td>";
                                        htmlcode += " <td></td>";
                                        htmlcode += "    <td></td>";
                                        htmlcode += "  </tr>";

                                        for (j = 1; j <= val_month * 12; j++) {
                                            interest_payment = temp * (item.InterestVND / 100 / 12);
                                            debit_payment = ba / (val_month * 12);
                                            temp = temp - debit_payment;
                                            monthlypayment = interest_payment + debit_payment;
                                            totalmonthlypayment += monthlypayment;
                                            totaltemp += temp;
                                            totaldebit_payment += debit_payment;
                                            totalinterest_payment += interest_payment;
                                            htmlcode += "<tr>";
                                            htmlcode += " <td>";
                                            htmlcode += "     <p style='text-align: center;'>" + j + "</p>";
                                            htmlcode += " </td>";
                                            htmlcode += "  <td>";
                                            if (temp >= 1) {
                                                htmlcode += "     <p style='text-align: center;'>" + number_format(temp, 0, ".", ",") + "</p>";
                                            }
                                            else {
                                                htmlcode += "     <p style='text-align: center;'>0</p>";
                                            }
                                            htmlcode += "  </td>";
                                            htmlcode += " <td>";
                                            htmlcode += "     <p style='text-align: center;'>" + number_format(monthlypayment, 0, ".", ",") + "</p>";
                                            htmlcode += "  </td>";
                                            htmlcode += " <td>";
                                            htmlcode += "      <p style='text-align: center;'>" + number_format(interest_payment, 0, ".", ",") + "</p>";
                                            htmlcode += "  </td>";
                                            htmlcode += "  <td>";
                                            htmlcode += "      <p style='text-align: center;'>" + number_format(debit_payment, 0, ".", ",") + "</p>";
                                            htmlcode += "   </td>";
                                            htmlcode += "   </tr>";
                                        }
                                        htmlcode += " <tr>";
                                        htmlcode += "    <td colspan='2'>";
                                        htmlcode += "         <p style='text-align: center;'>Total</p>";
                                        htmlcode += "    </td>";
                                        htmlcode += "   <td>";
                                        htmlcode += "       <p style='text-align: center;'>" + number_format(totalmonthlypayment, 0, ".", ",") + "</p>";
                                        htmlcode += "  </td>";
                                        htmlcode += "  <td>";
                                        htmlcode += "       <p style='text-align: center;'>" + number_format(totalinterest_payment, 0, ".", ",") + "</p>";
                                        htmlcode += "   </td>";
                                        htmlcode += "  <td>";
                                        htmlcode += "       <p style='text-align: center;'>" + number_format(totaldebit_payment, 0, ".", ",") + "</p>";
                                        htmlcode += "  </td>";
                                        htmlcode += " </tr>";
                                        htmlcode += "  </table>";
                                        htmlcode += "  </td>";
                                        htmlcode += "  </tr>";
                                        temp = ba;
                                        interest_payment = 0;
                                        debit_payment = 0;
                                        totaltemp = 0;
                                        totalinterest_payment = 0;
                                        totaldebit_payment = 0;
                                        monthlypayment = 0;
                                        totalmonthlypayment = 0;
                                    });
                                }
                                else {
                                    var payment = 0;
                                    $(rvdata).each(function (index, item) {
                                        var total = 0;
                                        for (i = 1; i <= val_month * 12; i++) {
                                            total += Math.pow((1 + (item.InterestVND / 100 / 12)), -i);
                                        }
                                        htmlcode += "<tr>";
                                        htmlcode += " <td class='td-bank-saving'>";
                                        htmlcode += " <a title='Xem chi tiết' href='" + AppUrl + "/home-equity-loan/" + convertounsign(item.CompanyName).toLowerCase() + "/" + convertounsign(item.HomeEquityLoanName).toLowerCase() + "/" + item.HomeEquityLoanID + "'><img alt='' src='/Content/UpLoad/Images/" + item.CompanyImg + "' /></a>";
                                        htmlcode += "<p class='bank-title'><a title='" + item.CompanyName + "' href='" + AppUrl + "/home-equity-loan/" + convertounsign(item.CompanyName).toLowerCase() + "/" + item.CompanyID + "'>" + item.CompanyName + "</a>" + item.HomeEquityLoanName + "</p>";
                                        htmlcode += " </td>";
                                        htmlcode += " <td style='vertical-align:middle;'>";
                                        htmlcode += "	<p style='text-align:center;'>" + item.MaximumBalance.replace(".", ",").replace(".", ",").replace(".", ",") + "</p>";
                                        htmlcode += "</td>";
                                        htmlcode += " <td style='vertical-align: middle;'>";
                                        htmlcode += " <p style='text-align: center;'>" + val_month + " Year</p>";
                                        htmlcode += "  </td>";
                                        if (item.InterestVND != 0) {
                                            htmlcode += " <td style='vertical-align:middle;'>";
                                            htmlcode += "<p class='highlight-blue text-p'>" + item.InterestVND + " %</p>";
                                            htmlcode += " </td>";
                                            htmlcode += " <td style='vertical-align:middle;'>";
                                            htmlcode += "<p class='highlight-blue text-p'>" + number_format(ba / total, 0, ".", ",") + "</p>";
                                            htmlcode += " <a href='#table-" + convertounsign(item.HomeEquityLoanName) + "-" + item.HomeEquityLoanID + "' title='Reference repayment schedule' id='tableloanpayment-" + item.HomeEquityLoanID + "'  class='table-loan-payment'>Reference repayment schedule</a>";
                                            htmlcode += " </td>";
                                        }
                                        else {
                                            htmlcode += " <td style='vertical-align:middle;' colspan='2'>";
                                            htmlcode += "<p class='highlight-blue-1 text-p'>Please kindly click on \"Apply\" button to contact us</p>";
                                            htmlcode += " </td>";
                                        }
                                        htmlcode += " <td class='td-btn'>";
                                        htmlcode += "	<a class='btn-app' href='" + AppUrl + "/home-equity-loan/apply/" + item.HomeEquityLoanID + "'>Apply >></a>";
                                        htmlcode += "<a href='#" + convertounsign(item.HomeEquityLoanName.toLowerCase()) + "-" + item.HomeEquityLoanID + "' class='more-link' onclick='return viewmore(this)' title='More Info'>More Info</a>";
                                        htmlcode += "</td>";
                                        htmlcode += " </tr>";
                                        htmlcode += "<tr id='" + convertounsign(item.HomeEquityLoanName.toLowerCase()) + "-" + item.HomeEquityLoanID + "' class='more-info' style='display: none;'>";
                                        htmlcode += "<td colspan='6'>";
                                        htmlcode += " <div class='more-info-top' >";
                                        htmlcode += " <div class='more-info-wrapper'>";
                                        htmlcode += "<h4>Benefit & Feature</h4>";
                                        htmlcode += "<div class='item-list'>";
                                        htmlcode += item.Benefit;
                                        htmlcode += "</div>";
                                        htmlcode += "</div>";
                                        htmlcode += "<div class='more-info-wrapper'>";
                                        htmlcode += "<h4>Fees</h4>";
                                        htmlcode += " <div class='item-list'>";
                                        htmlcode += item.FeeContent;
                                        htmlcode += "</div>";
                                        htmlcode += " </div>";
                                        htmlcode += "<div class='more-info-wrapper'>";
                                        htmlcode += "<h4>More Infomation</h4>";
                                        htmlcode += " <div class='item-list'>";
                                        htmlcode += item.MoreInfo;
                                        htmlcode += "</div>  ";
                                        htmlcode += " </div>";
                                        htmlcode += "</div>";
                                        htmlcode += "</td>";
                                        htmlcode += "</tr>";
                                        htmlcode += "    <tr  id='table-" + convertounsign(item.HomeEquityLoanName) + "-" + item.HomeEquityLoanID + "' style='display:none;'>";
                                        htmlcode += "<td>";
                                        htmlcode += "   <table class='product-table-loan'>";
                                        htmlcode += "   <tr>";
                                        htmlcode += "   <th style='width: 10%'>Month</th>";
                                        htmlcode += " <th>Outstanding Principal<br />(VND)</th>";
                                        htmlcode += "  <th>Monthly Payable <br />(VND)</th>";
                                        htmlcode += "  <th>Interest Payable <br />(VND)</th>";
                                        htmlcode += "   <th>Original Debt Payable<br /> (VND)</th>";
                                        htmlcode += " </tr>";
                                        htmlcode += "<tr>";
                                        htmlcode += "  <td></td>";
                                        htmlcode += " <td>";
                                        htmlcode += "   <p style='text-align: center;'>" + number_format(temp, 0, ".", ",") + "</p>'";
                                        htmlcode += " </td>";
                                        htmlcode += " <td></td>";
                                        htmlcode += " <td></td>";
                                        htmlcode += "    <td></td>";
                                        htmlcode += "  </tr>";

                                        for (j = 1; j <= val_month * 12; j++) {
                                            interest_payment = temp * (item.InterestVND / 100 / 12);
                                            temp = ((1 + (item.InterestVND / 100 / 12))) * temp - (ba / total);
                                            debit_payment = (ba / total) - interest_payment;
                                            totaltemp += temp;
                                            totaldebit_payment += debit_payment;
                                            totalinterest_payment += interest_payment;
                                            htmlcode += "<tr>";
                                            htmlcode += " <td>";
                                            htmlcode += "     <p style='text-align: center;'>" + j + "</p>";
                                            htmlcode += " </td>";
                                            htmlcode += "  <td>";
                                            if (temp >= 1) {
                                                htmlcode += "     <p style='text-align: center;'>" + number_format(temp, 0, ".", ",") + "</p>";
                                            }
                                            else {
                                                htmlcode += "     <p style='text-align: center;'>0</p>";
                                            }
                                            htmlcode += "  </td>";
                                            htmlcode += " <td>";
                                            htmlcode += "     <p style='text-align: center;'>" + number_format(ba / total, 0, ".", ",") + "</p>";
                                            htmlcode += "  </td>";
                                            htmlcode += " <td>";
                                            htmlcode += "      <p style='text-align: center;'>" + number_format(interest_payment, 0, ".", ",") + "</p>";
                                            htmlcode += "  </td>";
                                            htmlcode += "  <td>";
                                            htmlcode += "      <p style='text-align: center;'>" + number_format(debit_payment, 0, ".", ",") + "</p>";
                                            htmlcode += "   </td>";
                                            htmlcode += "   </tr>";
                                        }
                                        htmlcode += " <tr>";
                                        htmlcode += "    <td colspan='2'>";
                                        htmlcode += "         <p style='text-align: center;'>Total</p>";
                                        htmlcode += "    </td>";
                                        htmlcode += "   <td>";
                                        htmlcode += "       <p style='text-align: center;'>" + number_format((ba / total) * val_month * 12, 0, ".", ",") + "</p>";
                                        htmlcode += "  </td>";
                                        htmlcode += "  <td>";
                                        htmlcode += "       <p style='text-align: center;'>" + number_format(totalinterest_payment, 0, ".", ",") + "</p>";
                                        htmlcode += "   </td>";
                                        htmlcode += "  <td>";
                                        htmlcode += "       <p style='text-align: center;'>" + number_format(totaldebit_payment, 0, ".", ",") + "</p>";
                                        htmlcode += "  </td>";
                                        htmlcode += " </tr>";
                                        htmlcode += "  </table>";
                                        htmlcode += "  </td>";
                                        htmlcode += "  </tr>";
                                        temp = ba;
                                        interest_payment = 0;
                                        debit_payment = 0;
                                        totaltemp = 0;
                                        totalinterest_payment = 0;
                                        totaldebit_payment = 0;
                                    });
                                }


                                $("#product-table tbody").html("");
                                $("#product-table tbody").append(htmlcode);
                                $("#product-table").trigger("update");
                                $('tbody > tr:visible').removeClass('odd even').filter(':even').addClass('odd').end().filter(':odd').addClass('even');
                                $(".table-loan-payment").fancybox({
                                    wrapCSS: 'fancybox-custom',
                                    closeClick: true,
                                    openEffect: 'elastic',
                                    closeEffect: 'elastic',
                                    helpers: {
                                        title: {
                                            type: 'float'
                                        }
                                    }
                                });
                            }
                            else {

                                htmlcode = "<tr><td colspan='6' style='margin-top: 10px;font-weight: bold;text-align: center;margin-bottom: 10px;'>No result</p></td></tr>";
                                $("#product-table tbody").html(htmlcode);
                            }
                        }
                    });
                }
            });
            $("#amount-homeequityloan").val(number_format($("#slider_amount").slider("value"), 0, ".", ","));
            val = $("#slider_amount").slider("value");
        }
    });
    $(function () {
        var lang = $("#CurrentLangCode").html();
        if (lang == "vi-VN") {
            $("#slider_year").slider({
                value: 1,
                min: 1,
                max: 20,
                step: 1,
                slide: function (event, ui) {
                    $("#years-homeequityloan").val(ui.value);

                    var AppUrl = $("#AppUrl").text();
                    var val = $("#amount-homeequityloan").val().replace(".", "").replace(".", "").replace(".", "");
                    var val_cate = $("#rel_cate").attr("rel");
                    var val_month = $("#years-homeequityloan").val();
                    var ba = parseFloat(val);

                    var temp = ba;
                    var interest_payment = 0;
                    var debit_payment = 0;
                    var totaltemp = 0;
                    var totalinterest_payment = 0;
                    var totaldebit_payment = 0;
                    var totalmonthlypayment = 0;
                    var monthlypayment = 0;
                    $.ajax({
                        type: "post",
                        url: AppUrl + "/HomeEquityLoan/getHomeEquityLoan",
                        data: { planid: val_cate, balance: ba, years: val_month },
                        dataType: "json",
                        success: function (rvdata) {
                            var htmlcode = "";
                            if (rvdata.length > 0) {
                                if (val_cate == 1) {
                                    $(rvdata).each(function (index, item) {
                                        htmlcode += "<tr>";
                                        htmlcode += " <td class='td-bank-saving'>";
                                        htmlcode += " <a title='Xem chi tiết' href='" + AppUrl + "/home-equity-loan/" + convertounsign(item.CompanyName).toLowerCase() + "/" + convertounsign(item.HomeEquityLoanName).toLowerCase() + "/" + item.HomeEquityLoanID + "'><img alt='' src='/Content/UpLoad/Images/" + item.CompanyImg + "' /></a>";
                                        htmlcode += "<p class='bank-title'><a title='" + item.CompanyName + "' href='" + AppUrl + "/home-equity-loan/" + convertounsign(item.CompanyName).toLowerCase() + "/" + item.CompanyID + "'>" + item.CompanyName + "</a>" + item.HomeEquityLoanName + "</p>";
                                        htmlcode += " </td>";
                                        htmlcode += " <td style='vertical-align:middle;'>";
                                        htmlcode += "	<p style='text-align:center;'>" + item.MaximumBalance + "</p>";
                                        htmlcode += "</td>";
                                        htmlcode += " <td style='vertical-align: middle;'>";
                                        htmlcode += " <p style='text-align: center;'>" + val_month + " Năm</p>";
                                        htmlcode += "  </td>";
                                        if (item.InterestVND != 0) {
                                            htmlcode += " <td style='vertical-align:middle;'>";
                                            htmlcode += "<p class='highlight-blue text-p'>" + item.InterestVND.toString().replace(".", ",") + " %</p>";
                                            htmlcode += " </td>";
                                            htmlcode += " <td style='vertical-align:middle;'>";
                                            htmlcode += " <a href='#table-" + convertounsign(item.HomeEquityLoanName) + "-" + item.HomeEquityLoanID + "' title='Lịch biểu trả nợ tham khảo' id='tableloanpayment-" + item.HomeEquityLoanID + "' class='table-loan-payment'>Lịch biểu trả nợ tham khảo</a>";
                                            htmlcode += " </td>";
                                        }
                                        else {
                                            htmlcode += " <td style='vertical-align:middle;' colspan='2'>";
                                            htmlcode += "<p class='highlight-blue-1 text-p'>Vui lòng nhấp vào nút tham gia để liên hệ với chúng tôi</p>";
                                            htmlcode += " </td>";
                                        }
                                        htmlcode += " <td class='td-btn'>";
                                        htmlcode += "	<a class='btn-app' href='" + AppUrl + "/home-equity-loan/apply/" + item.HomeEquityLoanID + "'>Tham gia >></a>";
                                        htmlcode += "<a href='#" + convertounsign(item.HomeEquityLoanName.toLowerCase()) + "-" + item.HomeEquityLoanID + "' class='more-link' onclick='return viewmore(this)' title='Xem thêm'>Xem thêm</a>";
                                        htmlcode += "</td>";
                                        htmlcode += " </tr>";
                                        htmlcode += "<tr id='" + convertounsign(item.HomeEquityLoanName.toLowerCase()) + "-" + item.HomeEquityLoanID + "' class='more-info' style='display: none;'>";
                                        htmlcode += "<td colspan='6'>";
                                        htmlcode += " <div class='more-info-top' >";
                                        htmlcode += " <div class='more-info-wrapper'>";
                                        htmlcode += "<h4>Quyền lợi & Tính năng</h4>";
                                        htmlcode += "<div class='item-list'>";
                                        htmlcode += item.Benefit;
                                        htmlcode += "</div>";
                                        htmlcode += "</div>";
                                        htmlcode += "<div class='more-info-wrapper'>";
                                        htmlcode += "<h4>Chi phí</h4>";
                                        htmlcode += " <div class='item-list'>";
                                        htmlcode += item.FeeContent;
                                        htmlcode += "</div>";
                                        htmlcode += " </div>";
                                        htmlcode += "<div class='more-info-wrapper'>";
                                        htmlcode += "<h4>Thông tin thêm</h4>";
                                        htmlcode += " <div class='item-list'>";
                                        htmlcode += item.MoreInfo;
                                        htmlcode += "</div>  ";
                                        htmlcode += " </div>";
                                        htmlcode += "</div>";
                                        htmlcode += "</td>";
                                        htmlcode += "</tr>";

                                        htmlcode += "    <tr  id='table-" + convertounsign(item.HomeEquityLoanName) + "-" + item.HomeEquityLoanID + "' style='display:none;'>";
                                        htmlcode += "<td>";
                                        htmlcode += "   <table class='product-table-loan'>";
                                        htmlcode += "   <tr>";
                                        htmlcode += "   <th style='width: 10%'>Tháng</th>";
                                        htmlcode += " <th>Khoảng dư nợ gốc<br />(VND)</th>";
                                        htmlcode += "  <th>Khoảng phải trả hàng tháng<br />(VND)</th>";
                                        htmlcode += "  <th>Lãi phải trả<br />(VND)</th>";
                                        htmlcode += "   <th>Nợ gốc phải trả<br /> (VND)</th>";
                                        htmlcode += " </tr>";
                                        htmlcode += "<tr>";
                                        htmlcode += "  <td></td>";
                                        htmlcode += " <td>";
                                        htmlcode += "   <p style='text-align: center;'>" + number_format(temp, 0, ",", ".") + "</p>'";
                                        htmlcode += " </td>";
                                        htmlcode += " <td></td>";
                                        htmlcode += " <td></td>";
                                        htmlcode += "    <td></td>";
                                        htmlcode += "  </tr>";

                                        for (j = 1; j <= val_month * 12; j++) {
                                            interest_payment = temp * (item.InterestVND / 100 / 12);
                                            debit_payment = ba / (val_month * 12);
                                            temp = temp - debit_payment;
                                            monthlypayment = interest_payment + debit_payment;
                                            totalmonthlypayment += monthlypayment;
                                            totaltemp += temp;
                                            totaldebit_payment += debit_payment;
                                            totalinterest_payment += interest_payment;
                                            htmlcode += "<tr>";
                                            htmlcode += " <td>";
                                            htmlcode += "     <p style='text-align: center;'>" + j + "</p>";
                                            htmlcode += " </td>";
                                            htmlcode += "  <td>";
                                            if (temp >= 1) {
                                                htmlcode += "     <p style='text-align: center;'>" + number_format(temp, 0, ",", ".") + "</p>";
                                            }
                                            else {
                                                htmlcode += "     <p style='text-align: center;'>0</p>";
                                            }
                                            htmlcode += "  </td>";
                                            htmlcode += " <td>";
                                            htmlcode += "     <p style='text-align: center;'>" + number_format(monthlypayment, 0, ",", ".") + "</p>";
                                            htmlcode += "  </td>";
                                            htmlcode += " <td>";
                                            htmlcode += "      <p style='text-align: center;'>" + number_format(interest_payment, 0, ",", ".") + "</p>";
                                            htmlcode += "  </td>";
                                            htmlcode += "  <td>";
                                            htmlcode += "      <p style='text-align: center;'>" + number_format(debit_payment, 0, ",", ".") + "</p>";
                                            htmlcode += "   </td>";
                                            htmlcode += "   </tr>";
                                        }
                                        htmlcode += " <tr>";
                                        htmlcode += "    <td colspan='2'>";
                                        htmlcode += "         <p style='text-align: center;'>Tổng</p>";
                                        htmlcode += "    </td>";
                                        htmlcode += "   <td>";
                                        htmlcode += "       <p style='text-align: center;'>" + number_format(totalmonthlypayment, 0, ",", ".") + "</p>";
                                        htmlcode += "  </td>";
                                        htmlcode += "  <td>";
                                        htmlcode += "       <p style='text-align: center;'>" + number_format(totalinterest_payment, 0, ",", ".") + "</p>";
                                        htmlcode += "   </td>";
                                        htmlcode += "  <td>";
                                        htmlcode += "       <p style='text-align: center;'>" + number_format(totaldebit_payment, 0, ",", ".") + "</p>";
                                        htmlcode += "  </td>";
                                        htmlcode += " </tr>";
                                        htmlcode += "  </table>";
                                        htmlcode += "  </td>";
                                        htmlcode += "  </tr>";
                                        temp = ba;
                                        interest_payment = 0;
                                        debit_payment = 0;
                                        totaltemp = 0;
                                        totalinterest_payment = 0;
                                        totaldebit_payment = 0;
                                        monthlypayment = 0;
                                        totalmonthlypayment = 0;
                                    });
                                }
                                else {
                                    var payment = 0;
                                    $(rvdata).each(function (index, item) {
                                        var total = 0;
                                        for (i = 1; i <= val_month * 12; i++) {
                                            total += Math.pow((1 + (item.InterestVND / 100 / 12)), -i);
                                        }
                                        htmlcode += "<tr>";
                                        htmlcode += " <td class='td-bank-saving'>";
                                        htmlcode += " <a title='Xem chi tiết' href='" + AppUrl + "/home-equity-loan/" + convertounsign(item.CompanyName).toLowerCase() + "/" + convertounsign(item.HomeEquityLoanName).toLowerCase() + "/" + item.HomeEquityLoanID + "'><img alt='' src='/Content/UpLoad/Images/" + item.CompanyImg + "' /></a>";
                                        htmlcode += "<p class='bank-title'><a title='" + item.CompanyName + "' href='" + AppUrl + "/home-equity-loan/" + convertounsign(item.CompanyName).toLowerCase() + "/" + item.CompanyID + "'>" + item.CompanyName + "</a>" + item.HomeEquityLoanName + "</p>";
                                        htmlcode += " </td>";
                                        htmlcode += " <td style='vertical-align:middle;'>";
                                        htmlcode += "	<p style='text-align:center;'>" + item.MaximumBalance + "</p>";
                                        htmlcode += "</td>";
                                        htmlcode += " <td style='vertical-align: middle;'>";
                                        htmlcode += " <p style='text-align: center;'>" + val_month + " Năm</p>";
                                        htmlcode += "  </td>";
                                        if (item.InterestVND != 0) {
                                            htmlcode += " <td style='vertical-align:middle;'>";
                                            htmlcode += "<p class='highlight-blue text-p'>" + item.InterestVND.toString().replace(".", ",") + " %</p>";
                                            htmlcode += " </td>";
                                            htmlcode += " <td style='vertical-align:middle;'>";
                                            htmlcode += "<p class='highlight-blue text-p'>" + number_format(ba / total, 0, ",", ".") + "</p>";
                                            htmlcode += " <a href='#table-" + convertounsign(item.HomeEquityLoanName) + "-" + item.HomeEquityLoanID + "' title='Lịch biểu trả nợ tham khảo' id='tableloanpayment-" + item.HomeEquityLoanID + "'  class='table-loan-payment'>Lịch biểu trả nợ tham khảo</a>";
                                            htmlcode += " </td>";
                                        }
                                        else {
                                            htmlcode += " <td style='vertical-align:middle;' colspan='2'>";
                                            htmlcode += "<p class='highlight-blue-1 text-p'>Vui lòng nhấp vào nút tham gia để liên hệ với chúng tôi</p>";
                                            htmlcode += " </td>";
                                        }
                                        htmlcode += " <td class='td-btn'>";
                                        htmlcode += "	<a class='btn-app' href='" + AppUrl + "/home-equity-loan/apply/" + item.HomeEquityLoanID + "'>Tham gia >></a>";
                                        htmlcode += "<a href='#" + convertounsign(item.HomeEquityLoanName.toLowerCase()) + "-" + item.HomeEquityLoanID + "' class='more-link' onclick='return viewmore(this)' title='Xem thêm'>Xem thêm</a>";
                                        htmlcode += "</td>";
                                        htmlcode += " </tr>";
                                        htmlcode += "<tr id='" + convertounsign(item.HomeEquityLoanName.toLowerCase()) + "-" + item.HomeEquityLoanID + "' class='more-info' style='display: none;'>";
                                        htmlcode += "<td colspan='6'>";
                                        htmlcode += " <div class='more-info-top' >";
                                        htmlcode += " <div class='more-info-wrapper'>";
                                        htmlcode += "<h4>Quyền lợi & Tính năng</h4>";
                                        htmlcode += "<div class='item-list'>";
                                        htmlcode += item.Benefit;
                                        htmlcode += "</div>";
                                        htmlcode += "</div>";
                                        htmlcode += "<div class='more-info-wrapper'>";
                                        htmlcode += "<h4>Chi phí</h4>";
                                        htmlcode += " <div class='item-list'>";
                                        htmlcode += item.FeeContent;
                                        htmlcode += "</div>";
                                        htmlcode += " </div>";
                                        htmlcode += "<div class='more-info-wrapper'>";
                                        htmlcode += "<h4>Thông tin thêm</h4>";
                                        htmlcode += " <div class='item-list'>";
                                        htmlcode += item.MoreInfo;
                                        htmlcode += "</div>  ";
                                        htmlcode += " </div>";
                                        htmlcode += "</div>";
                                        htmlcode += "</td>";
                                        htmlcode += "</tr>";

                                        htmlcode += "    <tr  id='table-" + convertounsign(item.HomeEquityLoanName) + "-" + item.HomeEquityLoanID + "' style='display:none;'>";
                                        htmlcode += "<td>";
                                        htmlcode += "   <table class='product-table-loan'>";
                                        htmlcode += "   <tr>";
                                        htmlcode += "   <th style='width: 10%'>Tháng</th>";
                                        htmlcode += " <th>Khoảng dư nợ gốc<br />(VND)</th>";
                                        htmlcode += "  <th>Khoảng phải trả hàng tháng<br />(VND)</th>";
                                        htmlcode += "  <th>Lãi phải trả<br />(VND)</th>";
                                        htmlcode += "   <th>Nợ gốc phải trả<br /> (VND)</th>";
                                        htmlcode += " </tr>";
                                        htmlcode += "<tr>";
                                        htmlcode += "  <td></td>";
                                        htmlcode += " <td>";
                                        htmlcode += "   <p style='text-align: center;'>" + number_format(temp, 0, ",", ".") + "</p>'";
                                        htmlcode += " </td>";
                                        htmlcode += " <td></td>";
                                        htmlcode += " <td></td>";
                                        htmlcode += "    <td></td>";
                                        htmlcode += "  </tr>";

                                        for (j = 1; j <= val_month * 12; j++) {
                                            interest_payment = temp * (item.InterestVND / 100 / 12);
                                            temp = ((1 + (item.InterestVND / 100 / 12))) * temp - (ba / total);
                                            debit_payment = (ba / total) - interest_payment;
                                            totaltemp += temp;
                                            totaldebit_payment += debit_payment;
                                            totalinterest_payment += interest_payment;
                                            htmlcode += "<tr>";
                                            htmlcode += " <td>";
                                            htmlcode += "     <p style='text-align: center;'>" + j + "</p>";
                                            htmlcode += " </td>";
                                            htmlcode += "  <td>";
                                            if (temp >= 1) {
                                                htmlcode += "     <p style='text-align: center;'>" + number_format(temp, 0, ",", ".") + "</p>";
                                            }
                                            else {
                                                htmlcode += "     <p style='text-align: center;'>0</p>";
                                            }
                                            htmlcode += "  </td>";
                                            htmlcode += " <td>";
                                            htmlcode += "     <p style='text-align: center;'>" + number_format(ba / total, 0, ",", ".") + "</p>";
                                            htmlcode += "  </td>";
                                            htmlcode += " <td>";
                                            htmlcode += "      <p style='text-align: center;'>" + number_format(interest_payment, 0, ",", ".") + "</p>";
                                            htmlcode += "  </td>";
                                            htmlcode += "  <td>";
                                            htmlcode += "      <p style='text-align: center;'>" + number_format(debit_payment, 0, ",", ".") + "</p>";
                                            htmlcode += "   </td>";
                                            htmlcode += "   </tr>";
                                        }
                                        htmlcode += " <tr>";
                                        htmlcode += "    <td colspan='2'>";
                                        htmlcode += "         <p style='text-align: center;'>Tổng</p>";
                                        htmlcode += "    </td>";
                                        htmlcode += "   <td>";
                                        htmlcode += "       <p style='text-align: center;'>" + number_format((ba / total) * val_month * 12, 0, ",", ".") + "</p>";
                                        htmlcode += "  </td>";
                                        htmlcode += "  <td>";
                                        htmlcode += "       <p style='text-align: center;'>" + number_format(totalinterest_payment, 0, ",", ".") + "</p>";
                                        htmlcode += "   </td>";
                                        htmlcode += "  <td>";
                                        htmlcode += "       <p style='text-align: center;'>" + number_format(totaldebit_payment, 0, ",", ".") + "</p>";
                                        htmlcode += "  </td>";
                                        htmlcode += " </tr>";
                                        htmlcode += "  </table>";
                                        htmlcode += "  </td>";
                                        htmlcode += "  </tr>";
                                        temp = ba;
                                        interest_payment = 0;
                                        debit_payment = 0;
                                        totaltemp = 0;
                                        totalinterest_payment = 0;
                                        totaldebit_payment = 0;

                                    });
                                }

                                $("#product-table tbody").html("");
                                $("#product-table tbody").append(htmlcode);
                                $("#product-table").trigger("update");
                                $('tbody > tr:visible').removeClass('odd even').filter(':even').addClass('odd').end().filter(':odd').addClass('even');
                                $(".table-loan-payment").fancybox({
                                    wrapCSS: 'fancybox-custom',
                                    closeClick: true,
                                    openEffect: 'elastic',
                                    closeEffect: 'elastic',
                                    helpers: {
                                        title: {
                                            type: 'float'
                                        }
                                    }
                                });
                            }
                            else {
                                htmlcode = "<tr><td colspan='6' style='margin-top: 10px;font-weight: bold;text-align: center;margin-bottom: 10px;'>Không có dữ liệu phù hợp</p></td></tr>";
                                $("#product-table tbody").html(htmlcode);

                            }
                        }
                    });
                }
            });
            $("#years-homeequityloan").val($("#slider_year").slider("value"));

        }
        else {
            $("#slider_year").slider({
                value: 1,
                min: 1,
                max: 20,
                step: 1,
                slide: function (event, ui) {
                    $("#years-homeequityloan").val(ui.value);

                    var AppUrl = $("#AppUrl").text();
                    var val = $("#amount-homeequityloan").val().replace(",", "").replace(",", "").replace(",", "");
                    var val_cate = $("#rel_cate").attr("rel");
                    var val_month = $("#years-homeequityloan").val();
                    var ba = parseFloat(val);

                    var temp = ba;
                    var interest_payment = 0;
                    var debit_payment = 0;
                    var totaltemp = 0;
                    var totalinterest_payment = 0;
                    var totaldebit_payment = 0;
                    var totalmonthlypayment = 0;
                    var monthlypayment = 0;
                    $.ajax({
                        type: "post",
                        url: AppUrl + "/HomeEquityLoan/getHomeEquityLoan",
                        data: { planid: val_cate, balance: ba, years: val_month },
                        dataType: "json",
                        success: function (rvdata) {
                            var htmlcode = "";
                            if (rvdata.length > 0) {

                                if (val_cate == 1) {
                                    $(rvdata).each(function (index, item) {
                                        htmlcode += "<tr>";
                                        htmlcode += " <td class='td-bank-saving'>";
                                        htmlcode += " <a title='View Detail' href='" + AppUrl + "/home-equity-loan/" + convertounsign(item.CompanyName).toLowerCase() + "/" + convertounsign(item.HomeEquityLoanName).toLowerCase() + "/" + item.HomeEquityLoanID + "'><img alt='' src='/Content/UpLoad/Images/" + item.CompanyImg + "' /></a>";
                                        htmlcode += "<p class='bank-title'><a title='" + item.CompanyName + "' href='" + AppUrl + "/home-equity-loan/" + convertounsign(item.CompanyName).toLowerCase() + "/" + item.CompanyID + "'>" + item.CompanyName + "</a>" + item.HomeEquityLoanName + "</p>";
                                        htmlcode += " </td>";
                                        htmlcode += " <td style='vertical-align:middle;'>";
                                        htmlcode += "	<p style='text-align:center;'>" + item.MaximumBalance.replace(".", ",").replace(".", ",").replace(".", ",") + "</p>";
                                        htmlcode += "</td>";
                                        htmlcode += " <td style='vertical-align: middle;'>";
                                        htmlcode += " <p style='text-align: center;'>" + val_month + " Year</p>";
                                        htmlcode += "  </td>";
                                        if (item.InterestVND != 0) {
                                            htmlcode += " <td style='vertical-align:middle;'>";
                                            htmlcode += "<p class='highlight-blue text-p'>" + item.InterestVND + " %</p>";
                                            htmlcode += " </td>";
                                            htmlcode += " <td style='vertical-align:middle;'>";
                                            htmlcode += " <a href='#table-" + convertounsign(item.HomeEquityLoanName) + "-" + item.HomeEquityLoanID + "' title='Reference repayment schedule' id='tableloanpayment-" + item.HomeEquityLoanID + "'  class='table-loan-payment'>Reference repayment schedule</a>";
                                            htmlcode += " </td>";
                                        }
                                        else {
                                            htmlcode += " <td style='vertical-align:middle;' colspan='2'>";
                                            htmlcode += "<p class='highlight-blue-1 text-p'>Please kindly click on \"Apply\" button to contact us</p>";
                                            htmlcode += " </td>";
                                        }
                                        htmlcode += " <td class='td-btn'>";
                                        htmlcode += "	<a class='btn-app' href='" + AppUrl + "/home-equity-loan/apply/" + item.HomeEquityLoanID + "'>Apply >></a>";
                                        htmlcode += "<a href='#" + convertounsign(item.HomeEquityLoanName.toLowerCase()) + "-" + item.HomeEquityLoanID + "' class='more-link' onclick='return viewmore(this)' title='More Info'>More Info</a>";
                                        htmlcode += "</td>";
                                        htmlcode += " </tr>";
                                        htmlcode += "<tr id='" + convertounsign(item.HomeEquityLoanName.toLowerCase()) + "-" + item.HomeEquityLoanID + "' class='more-info' style='display: none;'>";
                                        htmlcode += "<td colspan='6'>";
                                        htmlcode += " <div class='more-info-top' >";
                                        htmlcode += " <div class='more-info-wrapper'>";
                                        htmlcode += "<h4>Benefit & Feature</h4>";
                                        htmlcode += "<div class='item-list'>";
                                        htmlcode += item.Benefit;
                                        htmlcode += "</div>";
                                        htmlcode += "</div>";
                                        htmlcode += "<div class='more-info-wrapper'>";
                                        htmlcode += "<h4>Fees</h4>";
                                        htmlcode += " <div class='item-list'>";
                                        htmlcode += item.FeeContent;
                                        htmlcode += "</div>";
                                        htmlcode += " </div>";
                                        htmlcode += "<div class='more-info-wrapper'>";
                                        htmlcode += "<h4>More Infomation</h4>";
                                        htmlcode += " <div class='item-list'>";
                                        htmlcode += item.MoreInfo;
                                        htmlcode += "</div>  ";
                                        htmlcode += " </div>";
                                        htmlcode += "</div>";
                                        htmlcode += "</td>";
                                        htmlcode += "</tr>";

                                        htmlcode += "    <tr  id='table-" + convertounsign(item.HomeEquityLoanName) + "-" + item.HomeEquityLoanID + "' style='display:none;'>";
                                        htmlcode += "<td>";
                                        htmlcode += "   <table class='product-table-loan'>";
                                        htmlcode += "   <tr>";
                                        htmlcode += "   <th style='width: 10%'>Month</th>";
                                        htmlcode += " <th>Outstanding Principal<br />(VND)</th>";
                                        htmlcode += "  <th>Monthly Payable <br />(VND)</th>";
                                        htmlcode += "  <th>Interest Payable <br />(VND)</th>";
                                        htmlcode += "   <th>Original Debt Payable<br /> (VND)</th>";
                                        htmlcode += " </tr>";
                                        htmlcode += "<tr>";
                                        htmlcode += "  <td></td>";
                                        htmlcode += " <td>";
                                        htmlcode += "   <p style='text-align: center;'>" + number_format(temp, 0, ".", ",") + "</p>'";
                                        htmlcode += " </td>";
                                        htmlcode += " <td></td>";
                                        htmlcode += " <td></td>";
                                        htmlcode += "    <td></td>";
                                        htmlcode += "  </tr>";

                                        for (j = 1; j <= val_month * 12; j++) {
                                            interest_payment = temp * (item.InterestVND / 100 / 12);
                                            debit_payment = ba / (val_month * 12);
                                            temp = temp - debit_payment;
                                            monthlypayment = interest_payment + debit_payment;
                                            totalmonthlypayment += monthlypayment;
                                            totaltemp += temp;
                                            totaldebit_payment += debit_payment;
                                            totalinterest_payment += interest_payment;
                                            htmlcode += "<tr>";
                                            htmlcode += " <td>";
                                            htmlcode += "     <p style='text-align: center;'>" + j + "</p>";
                                            htmlcode += " </td>";
                                            htmlcode += "  <td>";
                                            if (temp >= 1) {
                                                htmlcode += "     <p style='text-align: center;'>" + number_format(temp, 0, ".", ",") + "</p>";
                                            }
                                            else {
                                                htmlcode += "     <p style='text-align: center;'>0</p>";
                                            }
                                            htmlcode += "  </td>";
                                            htmlcode += " <td>";
                                            htmlcode += "     <p style='text-align: center;'>" + number_format(monthlypayment, 0, ".", ",") + "</p>";
                                            htmlcode += "  </td>";
                                            htmlcode += " <td>";
                                            htmlcode += "      <p style='text-align: center;'>" + number_format(interest_payment, 0, ".", ",") + "</p>";
                                            htmlcode += "  </td>";
                                            htmlcode += "  <td>";
                                            htmlcode += "      <p style='text-align: center;'>" + number_format(debit_payment, 0, ".", ",") + "</p>";
                                            htmlcode += "   </td>";
                                            htmlcode += "   </tr>";
                                        }
                                        htmlcode += " <tr>";
                                        htmlcode += "    <td colspan='2'>";
                                        htmlcode += "         <p style='text-align: center;'>Total</p>";
                                        htmlcode += "    </td>";
                                        htmlcode += "   <td>";
                                        htmlcode += "       <p style='text-align: center;'>" + number_format(totalmonthlypayment, 0, ".", ",") + "</p>";
                                        htmlcode += "  </td>";
                                        htmlcode += "  <td>";
                                        htmlcode += "       <p style='text-align: center;'>" + number_format(totalinterest_payment, 0, ".", ",") + "</p>";
                                        htmlcode += "   </td>";
                                        htmlcode += "  <td>";
                                        htmlcode += "       <p style='text-align: center;'>" + number_format(totaldebit_payment, 0, ".", ",") + "</p>";
                                        htmlcode += "  </td>";
                                        htmlcode += " </tr>";
                                        htmlcode += "  </table>";
                                        htmlcode += "  </td>";
                                        htmlcode += "  </tr>";
                                        temp = ba;
                                        interest_payment = 0;
                                        debit_payment = 0;
                                        totaltemp = 0;
                                        totalinterest_payment = 0;
                                        totaldebit_payment = 0;
                                        monthlypayment = 0;
                                        totalmonthlypayment = 0;
                                    });
                                }
                                else {
                                    var payment = 0;
                                    $(rvdata).each(function (index, item) {
                                        var total = 0;
                                        for (i = 1; i <= val_month * 12; i++) {
                                            total += Math.pow((1 + (item.InterestVND / 100 / 12)), -i);
                                        }
                                        htmlcode += "<tr>";
                                        htmlcode += " <td class='td-bank-saving'>";
                                        htmlcode += " <a title='Xem chi tiết' href='" + AppUrl + "/home-equity-loan/" + convertounsign(item.CompanyName).toLowerCase() + "/" + convertounsign(item.HomeEquityLoanName).toLowerCase() + "/" + item.HomeEquityLoanID + "'><img alt='' src='/Content/UpLoad/Images/" + item.CompanyImg + "' /></a>";
                                        htmlcode += "<p class='bank-title'><a title='" + item.CompanyName + "' href='" + AppUrl + "/home-equity-loan/" + convertounsign(item.CompanyName).toLowerCase() + "/" + item.CompanyID + "'>" + item.CompanyName + "</a>" + item.HomeEquityLoanName + "</p>";
                                        htmlcode += " </td>";
                                        htmlcode += " <td style='vertical-align:middle;'>";
                                        htmlcode += "	<p style='text-align:center;'>" + item.MaximumBalance.replace(".", ",").replace(".", ",").replace(".", ",") + "</p>";
                                        htmlcode += "</td>";
                                        htmlcode += " <td style='vertical-align: middle;'>";
                                        htmlcode += " <p style='text-align: center;'>" + val_month + " Year</p>";
                                        htmlcode += "  </td>";
                                        if (item.InterestVND != 0) {
                                            htmlcode += " <td style='vertical-align:middle;'>";
                                            htmlcode += "<p class='highlight-blue text-p'>" + item.InterestVND + " %</p>";
                                            htmlcode += " </td>";
                                            htmlcode += " <td style='vertical-align:middle;'>";
                                            htmlcode += "<p class='highlight-blue text-p'>" + number_format(ba / total, 0, ".", ",") + "</p>";
                                            htmlcode += " <a href='#table-" + convertounsign(item.HomeEquityLoanName) + "-" + item.HomeEquityLoanID + "' title='Reference repayment schedule' id='tableloanpayment-" + item.HomeEquityLoanID + "'  class='table-loan-payment'>Reference repayment schedule</a>";
                                            htmlcode += " </td>";
                                        }
                                        else {
                                            htmlcode += " <td style='vertical-align:middle;' colspan='2'>";
                                            htmlcode += "<p class='highlight-blue-1 text-p'>Please kindly click on \"Apply\" button to contact us</p>";
                                            htmlcode += " </td>";
                                        }
                                        htmlcode += " <td class='td-btn'>";
                                        htmlcode += "	<a class='btn-app' href='" + AppUrl + "/home-equity-loan/apply/" + item.HomeEquityLoanID + "'>Apply >></a>";
                                        htmlcode += "<a href='#" + convertounsign(item.HomeEquityLoanName.toLowerCase()) + "-" + item.HomeEquityLoanID + "' class='more-link' onclick='return viewmore(this)' title='More Info'>More Info</a>";
                                        htmlcode += "</td>";
                                        htmlcode += " </tr>";
                                        htmlcode += "<tr id='" + convertounsign(item.HomeEquityLoanName.toLowerCase()) + "-" + item.HomeEquityLoanID + "' class='more-info' style='display: none;'>";
                                        htmlcode += "<td colspan='6'>";
                                        htmlcode += " <div class='more-info-top' >";
                                        htmlcode += " <div class='more-info-wrapper'>";
                                        htmlcode += "<h4>Benefit & Feature</h4>";
                                        htmlcode += "<div class='item-list'>";
                                        htmlcode += item.Benefit;
                                        htmlcode += "</div>";
                                        htmlcode += "</div>";
                                        htmlcode += "<div class='more-info-wrapper'>";
                                        htmlcode += "<h4>Fees</h4>";
                                        htmlcode += " <div class='item-list'>";
                                        htmlcode += item.FeeContent;
                                        htmlcode += "</div>";
                                        htmlcode += " </div>";
                                        htmlcode += "<div class='more-info-wrapper'>";
                                        htmlcode += "<h4>More Infomation</h4>";
                                        htmlcode += " <div class='item-list'>";
                                        htmlcode += item.MoreInfo;
                                        htmlcode += "</div>  ";
                                        htmlcode += " </div>";
                                        htmlcode += "</div>";
                                        htmlcode += "</td>";
                                        htmlcode += "</tr>";
                                        htmlcode += "    <tr  id='table-" + convertounsign(item.HomeEquityLoanName) + "-" + item.HomeEquityLoanID + "' style='display:none;'>";
                                        htmlcode += "<td>";
                                        htmlcode += "   <table class='product-table-loan'>";
                                        htmlcode += "   <tr>";
                                        htmlcode += "   <th style='width: 10%'>Month</th>";
                                        htmlcode += " <th>Outstanding Principal<br />(VND)</th>";
                                        htmlcode += "  <th>Monthly Payable <br />(VND)</th>";
                                        htmlcode += "  <th>Interest Payable <br />(VND)</th>";
                                        htmlcode += "   <th>Original Debt Payable<br /> (VND)</th>";
                                        htmlcode += " </tr>";
                                        htmlcode += "<tr>";
                                        htmlcode += "  <td></td>";
                                        htmlcode += " <td>";
                                        htmlcode += "   <p style='text-align: center;'>" + number_format(temp, 0, ".", ",") + "</p>'";
                                        htmlcode += " </td>";
                                        htmlcode += " <td></td>";
                                        htmlcode += " <td></td>";
                                        htmlcode += "    <td></td>";
                                        htmlcode += "  </tr>";

                                        for (j = 1; j <= val_month * 12; j++) {
                                            interest_payment = temp * (item.InterestVND / 100 / 12);
                                            temp = ((1 + (item.InterestVND / 100 / 12))) * temp - (ba / total);
                                            debit_payment = (ba / total) - interest_payment;
                                            totaltemp += temp;
                                            totaldebit_payment += debit_payment;
                                            totalinterest_payment += interest_payment;
                                            htmlcode += "<tr>";
                                            htmlcode += " <td>";
                                            htmlcode += "     <p style='text-align: center;'>" + j + "</p>";
                                            htmlcode += " </td>";
                                            htmlcode += "  <td>";
                                            if (temp >= 1) {
                                                htmlcode += "     <p style='text-align: center;'>" + number_format(temp, 0, ".", ",") + "</p>";
                                            }
                                            else {
                                                htmlcode += "     <p style='text-align: center;'>0</p>";
                                            }
                                            htmlcode += "  </td>";
                                            htmlcode += " <td>";
                                            htmlcode += "     <p style='text-align: center;'>" + number_format(ba / total, 0, ".", ",") + "</p>";
                                            htmlcode += "  </td>";
                                            htmlcode += " <td>";
                                            htmlcode += "      <p style='text-align: center;'>" + number_format(interest_payment, 0, ".", ",") + "</p>";
                                            htmlcode += "  </td>";
                                            htmlcode += "  <td>";
                                            htmlcode += "      <p style='text-align: center;'>" + number_format(debit_payment, 0, ".", ",") + "</p>";
                                            htmlcode += "   </td>";
                                            htmlcode += "   </tr>";
                                        }
                                        htmlcode += " <tr>";
                                        htmlcode += "    <td colspan='2'>";
                                        htmlcode += "         <p style='text-align: center;'>Total</p>";
                                        htmlcode += "    </td>";
                                        htmlcode += "   <td>";
                                        htmlcode += "       <p style='text-align: center;'>" + number_format((ba / total) * val_month * 12, 0, ".", ",") + "</p>";
                                        htmlcode += "  </td>";
                                        htmlcode += "  <td>";
                                        htmlcode += "       <p style='text-align: center;'>" + number_format(totalinterest_payment, 0, ".", ",") + "</p>";
                                        htmlcode += "   </td>";
                                        htmlcode += "  <td>";
                                        htmlcode += "       <p style='text-align: center;'>" + number_format(totaldebit_payment, 0, ".", ",") + "</p>";
                                        htmlcode += "  </td>";
                                        htmlcode += " </tr>";
                                        htmlcode += "  </table>";
                                        htmlcode += "  </td>";
                                        htmlcode += "  </tr>";
                                        temp = ba;
                                        interest_payment = 0;
                                        debit_payment = 0;
                                        totaltemp = 0;
                                        totalinterest_payment = 0;
                                        totaldebit_payment = 0;
                                    });
                                }


                                $("#product-table tbody").html("");
                                $("#product-table tbody").append(htmlcode);
                                $("#product-table").trigger("update");
                                $('tbody > tr:visible').removeClass('odd even').filter(':even').addClass('odd').end().filter(':odd').addClass('even');
                                $(".table-loan-payment").fancybox({
                                    wrapCSS: 'fancybox-custom',
                                    closeClick: true,
                                    openEffect: 'elastic',
                                    closeEffect: 'elastic',
                                    helpers: {
                                        title: {
                                            type: 'float'
                                        }
                                    }
                                });
                            }
                            else {

                                htmlcode = "<tr><td colspan='6' style='margin-top: 10px;font-weight: bold;text-align: center;margin-bottom: 10px;'>No result</p></td></tr>";
                                $("#product-table tbody").html(htmlcode);
                            }
                        }
                    });
                }
            });
            $("#years-homeequityloan").val($("#slider_year").slider("value"));
        }
    });
</script>
<script src="@Url.Content("~/content/js/jquery.tablesorter.min.js")" type="text/javascript"></script>
<script type="text/javascript">
    $(function () {
        $("#product-table").tablesorter({ headers: { 5: { sorter: false }, 2: { sorter: false } }, widthFixed: true, widgets: ['zebra'] });

    });
</script>
<div id="v3HomeBody">
    <div class="bread_crumb">
        <ul>
            <li><a href="/" class="bread_arrow" title="@FOResource.UI.Layout.lblhome">@FOResource.UI.Layout.lblhome</a></li>
            <li><a href="@Url.Action("Index", "HomeEquityLoan")" class="bread_arrow" title="@FOResource.UI.Layout.HomeEquityLoan">@FOResource.UI.Layout.HomeEquityLoan</a></li>
            <li class="lastli"><a href="@Url.Action("Index", "HomeEquityLoan")" class="bold" title="@FOResource.UI.Product.Deposit.selectpro">@FOResource.UI.Product.Deposit.selectpro</a></li>
        </ul>
    </div>
    <!--Close Bread crumb-->

    <!--Open Top Slider-->
    <div class="top_slider" id="afocus">
        <ol class="top_bar">
            <li style="width: 164px;"><a href="@Url.Action("Index", "HomeEquityLoan")" class="active" id="show_div"><span style="left: -13px;">@FOResource.UI.Layout.lblchoose</span></a> </li>
            <li style="width: 164px;"><a class="bar_2"><span style="left: -13px;">@FOResource.UI.Layout.lblinfo</span></a></li>
            <li style="width: 60px;"><a class="bar_3"><span style="left: -13px;">@FOResource.UI.Layout.lblcontract</span></a></li>
        </ol>
        <span class="h1replace">...</span>

    </div>
    <div class="clear"></div>
    <div class="pane-content">

        <div id="home-loan-calculator" style="height: 140px;">
            <div id="calculator-form">
                <form>
                    <h3>@FOResource.UI.Product.HomeLoan.loanamount</h3>
                    <div id="amount-wrapper">
                        <div class="slider1" id="slider_amount">
                            <div class="progress"></div>
                        </div>
                        <input type="text" class="amount" name="amount" id="amount-homeequityloan" /><span class="suffix"> VND</span>
                    </div>
                    <div class="clear"></div>
                    <h3>@FOResource.UI.Product.HomeLoan.loanperiod</h3>
                    <div id="tenure-wrapper">
                        <div class="slider1" id="slider_year">
                            <div class="progress"></div>
                        </div>
                        <input type="text" class="years" name="years" id="years-homeequityloan" /><span class="suffix"> @FOResource.UI.Layout.years</span>
                    </div>
                </form>
            </div>
            <div id="home-loan-tips">
                <h3>@FOResource.UI.Product.HomeLoan.payments</h3>
                <span style="float: left; width: 100%;">
                    @if (plan.Count > 0)
                    {
                        foreach (var ca in plan)
                        {

                            if (i == 1)
                            {
                        <span id="rel_cate" rel="@ca.HomeLoanPlanID"></span>
                        <label>
                            <input type="radio" onchange="return ajaxHomeEquityLoanplanid('@ca.HomeLoanPlanID')" checked="checked"  name="features" value="@ca.HomeLoanPlanID" />
                            @ca.HomeLoanPlanName</label>
                        <br />
                            }
                            else
                            {
                        <label>
                            <input type="radio"  name="features" onchange="return ajaxHomeEquityLoanplanid('@ca.HomeLoanPlanID')" value="@ca.HomeLoanPlanID" />
                            @ca.HomeLoanPlanName</label>
                        <br />
                            }
                            i = i + 1;


                        }
                    }

                </span>
                 <div class="clr"></div>
                <div class="social-like" style="margin-top:6px;">
                <div class="vnlike-fb">
                    <div class="fb-like" data-href="@Request.Url.AbsoluteUri" data-width="450" data-layout="button_count" data-show-faces="true" data-send="true"></div>
                </div>
                <div class="vnlike-google" >
                    <div class="g-plusone" data-size="medium" data-href="@Request.Url.AbsoluteUri"></div>
                </div>
            </div>
            </div>
        </div>
    </div>
    <table class="product-table" id="product-table">
        <thead>
            <tr>
                <th style="width: 25%;">@FOResource.UI.Product.Card.lblbank</th>
                <th style="width: 15%;">@FOResource.UI.CpanelLayout.maxbalanceloan<br />
                    (VND)</th>
                <th style="width: 13%;">@FOResource.UI.Product.HomeLoan.loanperiod</th>
                <th style="width: 14%;">@FOResource.UI.Product.Deposit.interest<br />@FOResource.UI.Product.Deposit.peryear</th>
                <th style="width: 17%;" id="th-loan">@FOResource.UI.Layout.amountpaymonth (VND)</th>
                <th style="width: 13%;">@FOResource.UI.Product.Card.lblapply1</th>
            </tr>
        </thead>
        <tbody>
            @if (shorttemloan.Count > 0)
            {
                foreach (var h in shorttemloan)
                {
                    double total = 0;
                    for (i = 1; i <= 12; i++)
                    {
                        total += Math.Pow((1 + (h.InterestVND / 100 / 12)), -i);
                    }
                <tr>
                    <td class="td-bank-saving">
                        <a title="@FOResource.UI.Layout.viewdetail" href="@Url.Action("Detail", "HomeEquityLoan", new { CompanyName = FO.Models.Conver.ConvertToUnSign(h.CompanyName).ToLower(), HomeEquityLoanName = FO.Models.Conver.ConvertToUnSign(h.HomeEquityLoanName).ToLower(), HomeEquityLoanID = h.HomeEquityLoanID })">
                            <img alt="" src="@Url.Content("~/Content/UpLoad/Images/" + h.CompanyImg + "")" /></a>
                        <p class="bank-title"><a title="@h.CompanyName" href="@Url.Action("TermSavingByProvider", "HomeEquityLoan", new { CompanyName = FO.Models.Conver.ConvertToUnSign(h.CompanyName).ToLower(), CompanyID = h.CompanyID })">@h.CompanyName</a>@h.HomeEquityLoanName</p>
                    </td>
                    <td style="vertical-align: middle;">
                       <p style="text-align: center;">@h.MaximumBalance.Replace(".", "" + FOResource.UI.Layout.currency + "")</p>
                    </td>
                    <td style="vertical-align: middle;">
                        <p style="text-align: center;">1 @FOResource.UI.Product.HomeLoan.years</p>
                    </td>
                    @if(h.InterestVND!=0)
                    {
                    <td style="vertical-align: middle;">
                       <p class="highlight-blue text-p">@h.InterestVND.ToString().Replace(".", "" + FOResource.UI.Layout.currency1 + "") %</p>
                    </td>
                    <td style="vertical-align: middle;">
                         <p class="highlight-blue text-p">@String.Format("{0:0,0}", 50000000 / total).Replace(",", "" + FOResource.UI.Layout.currency + "")</p>
                        <a href="#table-@FO.Models.Conver.ConvertToUnSign(h.HomeEquityLoanName).ToLower()-@h.HomeEquityLoanID" title="@FOResource.UI.Layout.debtpayment" id="tableloanpayment-@h.HomeEquityLoanID"  class="table-loan-payment">@FOResource.UI.Layout.debtpayment</a>
                    </td>
                    }
                    else
                    {
                        <td style="vertical-align: middle;" colspan="2">
                            <p class="highlight-blue-1 text-p">@FOResource.UI.Layout.applyplease</p>
                        </td>
                    }
                    <td class="td-btn">
                        @Html.ActionLink("" + FOResource.UI.Product.Card.lblapply + "", "HomeEquityLoanInfo", "HomeEquityLoan", new { HomeEquityLoanID = h.HomeEquityLoanID }, new { @class = "btn-app", rel = "" + h.HomeEquityLoanID + "" })
                        <a href="#@FO.Models.Conver.ConvertToUnSign(h.HomeEquityLoanName).ToLower()-@h.HomeEquityLoanID" class="more-link" onclick="return viewmore(this)" title="@FOResource.UI.Layout.moreinfo">@FOResource.UI.Layout.moreinfo</a>
                    </td>

                </tr>
                <tr id="@FO.Models.Conver.ConvertToUnSign(h.HomeEquityLoanName).ToLower()-@h.HomeEquityLoanID" class="more-info" style="display:none;" >
                    <td colspan="6">
                        <div class="more-info-top">
                            <div class="more-info-wrapper">
                                <h4>@FOResource.UI.Product.Card.lblbenefit &amp; @FOResource.UI.Product.Card.lblfeatures</h4>
                                <div class="item-list">
                                    @Html.Raw(h.Benefit)
                                </div>
                            </div>
                            <div class="more-info-wrapper">
                                <h4>@FOResource.UI.Layout.fee</h4>
                                <div class="item-list">
                                    @Html.Raw(h.FeeContent)
                                </div>

                            </div>
                            <div class="more-info-wrapper">
                                <h4>@FOResource.UI.Layout.moreinfomation</h4>
                                <div class="item-list">
                                    @Html.Raw(h.MoreInfo)

                                </div>
                            </div>
                        </div>
                    </td>
                </tr>
                <tr  id="table-@FO.Models.Conver.ConvertToUnSign(h.HomeEquityLoanName).ToLower()-@h.HomeEquityLoanID" style="display:none;">
                    <td>
                         <table class="product-table-loan">
                             <tr>
                                <th style="width: 10%">@FOResource.UI.Layout.month</th>
                                <th>@FOResource.UI.Layout.OutstandingPrincipal
                                    <br />
                                    (VND)</th>
                                <th>@FOResource.UI.Layout.MonthlyPayable<br />
                                    (VND)</th>
                                <th>@FOResource.UI.Layout.InterestPayable<br />
                                    (VND)</th>
                                <th>@FOResource.UI.Layout.OriginalDebtPayable<br />
                                    (VND)</th>
                            </tr>
                            <tr>

                                <td></td>
                                <td>
                                    <p style="text-align: center;">@String.Format("{0:0,0}", temp).Replace(",", "" + FOResource.UI.Layout.currency + "")</p>
                                </td>
                                <td></td>
                                <td></td>
                                <td></td>
                            </tr>

                            @for (j = 1; j <= 12; j++)
                            {
                                interest_payment = temp * (h.InterestVND / 100 / 12);
                                temp = ((1 + (h.InterestVND / 100 / 12))) * temp - (50000000 / total);
                                debit_payment = (50000000 / total) - interest_payment;
                                totaltemp += temp;
                                totaldebit_payment += debit_payment;
                                totalinterest_payment += interest_payment;
                                 <tr>
                                    <td>
                                        <p style="text-align: center;">@j</p>
                                    </td>

                                    <td>
                                        @if (temp >= 1)
                                        {
                                            <p style="text-align: center;">@String.Format("{0:0,0}", temp).Replace(",", "" + FOResource.UI.Layout.currency + "")</p>
                                        }
                                        else
                                        {
                                            <p style="text-align: center;">0</p>
                                        }
                                    </td>

                                    <td>
                                        <p style="text-align: center;">@String.Format("{0:0,0}", 50000000 / total).Replace(",", "" + FOResource.UI.Layout.currency + "")</p>
                                    </td>

                                    <td>
                                        <p style="text-align: center;">@String.Format("{0:0,0}", interest_payment).Replace(",", "" + FOResource.UI.Layout.currency + "")</p>
                                    </td>

                                    <td>
                                        <p style="text-align: center;">@String.Format("{0:0,0}", debit_payment).Replace(",", "" + FOResource.UI.Layout.currency + "")</p>
                                    </td>
                                </tr>
                            }
                            <tr>
                               <td colspan="2">
                                    <p style="text-align: center;">@FOResource.UI.Layout.total</p>
                                </td>
                                <td>
                                    <p style="text-align: center;">@String.Format("{0:0,0}", (50000000 / total) * 12).Replace(",", "" + FOResource.UI.Layout.currency + "")</p>
                                </td>

                                <td>
                                    <p style="text-align: center;">@String.Format("{0:0,0}", totalinterest_payment).Replace(",", "" + FOResource.UI.Layout.currency + "")</p>
                                </td>

                                <td>
                                    <p style="text-align: center;">@String.Format("{0:0,0}", totaldebit_payment).Replace(",", "" + FOResource.UI.Layout.currency + "")</p>
                                </td>
                            </tr>
                        </table>
                    </td>
                    @{
                            temp = 50000000;
                            totaltemp = 0;
                            totaldebit_payment = 0;
                            totalinterest_payment = 0;
                    }
                </tr>
               
                }
            }
        </tbody>
    </table>

    <!--Close Form Info-->
    <div class="bot-main">
        <div class="bottom_tabbed" style="float: left; width: 960px; margin-bottom: 30px;">
            <div class="bottom_center">
                @Html.Raw(ProDes.Description)
            </div>
            <div class="clr"></div>
            <p id="vnquestion-fb">@FOResource.UI.Layout.cmt</p>
            <div style="float: left;">

                <div class="clr"></div>
                <div id="fb-root"></div>
                <div class="fb-comments" data-href="@Request.Url.AbsoluteUri" data-width="645" style="margin-right:10px;"></div>
            </div>

            <div style="float: left;">

                <div id="vnbanknet-facebook" style="margin: 0;">
                    <div class="fb-like-box" data-href="http://facebook.com/vnbanknet" data-width="300" data-height="270" data-show-faces="true" data-header="false" data-stream="false" data-show-border="false"></div>
                </div>
            </div>

        </div>

        <div class="clr"></div>
    </div>


</div>
